fixed possible corruption of first bytes in file.

the recv() command to fetch filename_size and filename may fetch file
data which is later ignored (not written to file).
also used uint32_t and ntohl/htonl to serialize filename_size.