Send and receive data code
Portability

The code would fail if the sender and receiver platforms disagree on the size of integer.

The code would fail if the sender and receiver platforms disagree on the endianness of integer.
Partial reads

There is a chance that the very first read returns just a couple of bytes. The code still interprets it as a valid integer.
Overall

There is no need to use the same buffer for both size and payload.

m,n,k are patently bad variable names.
Recommendations

Implement a separate send_size() and read_size() routines.