Home > Software engineering > File when sending package sending and receiving package size is not consistent
File when sending package sending and receiving package size is not consistent
Time:10-09
Send (SOCKET s, const char FAR * buf, int len, int flags); Recv (SOCKET s, char FAR * buf, int len, int flags);
Using TCP send and receive data, send the file is about 2 m, split into multiple packages to send, send 5 k at a time, at the receiving end, every time I need to determine the received packet size, so use Int len=recv (s, buff, mMaxNub, int flags); Found that every time I send the buff to 5 k, when receiving judge len every time there are 9 k, receives is bigger than the package was sent the package, this is how to return a responsibility?
CodePudding user response:
TCP is streaming protocol, cannot guarantee that every time is the last time to send the size of the receive