title: How can I calculate the number of bytes in the packet payload?
body: <p>There is a client and a server, at application layer, a client is sending packets to server of random payload sizes. That means one packet can be of 1300 bytes, next packet can be of 450 bytes, and next packet can be of 1449 bytes and so on. At server how you can read payload data incoming from clients ? How much data your socket should read ? considering the fact that client can not send the payload size it is sending. How can server differentiate between individual packets of 1300, 450 and 1449 bytes. We are using POSIX sockets in C and working at application layer. Any code snippet will be helpful. </p>