This function returns nothing but 0.  Did you forget a non-zero return below the writeDatagram() call?