c# - Multiple messages in one BeginReceive -
if client sends multiple messages server on same socket, endreceive on server side keep messages seperated, or possible the server receive partial messages 2 seperate sends in single beginreceive?
assuming tcp, there're no message boundaries on socket. 1 send might consumed multiple receives , other way around, , partially. treat tcp socket stream. either send fixed-size messages know how many bytes read, or embed message size message (preferably @ beginning of message) can find out go.
edit:
to answer questions in comment - it's not "ms os" that's doing - it's tcp/ip stacks on both sides of connection. bytes written socket buffered inside kernel , sent on wire when network stack thinks it's best time (in-kernel timeout up, output queue reached tcp window size, etc. - it's in details of how tcp works). tcp (but not udp) kernel not keep track of application write boundaries, of how many bytes there send, how many have been ack-ed, etc. it's stream, os does not know application messages, bytes.
Comments
Post a Comment