You need to take into account endianess when transmitting 16, 32 and 64 bit integers to other computers.

A simple htons() on sending with a ntohs() on recieving fixes that.