c++ - FD_READ: recv() returning two packets at once -
i'm using winsock in application mantain client-server connection, , using non-blocking sockets in order that. when fd_read message, appears recv() returns not one, 2 packets.
i tried change sizes of packets differ each other , compared amount of data recv() returning. i'm 100% sure receive 2 packets time time. think ping function blamed. have thread in app sends ping message time time. other side replies message. not sure if that's best way whatever, doesn't matter right now.
what know sure these messages "mixed", recv() returns "ping request" , "ping answer" @ once. how happen? isn't recv() supposed return amount of data single send() call sent? if client or server gets "ping request" message , replies it, while sending own "ping request" message, if such unfortunate timing possible, shouldn't other side able differ 1 packet , return 1 per fd_read message?
tcp stream of data, not stream of packets. udp stream of packets. anthony said, if you're using tcp, have handle 1 section of data ends , next begins.
Comments
Post a Comment