• Advertisement

Archived

This topic is now archived and is closed to further replies.

Winsock EOF msg?

This topic is 5057 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Advertisement
If the data happens to contain the character sequence "EOF," or if the message "EOF" happens to be fragmented and delivered as first "EO" and then "F", this scheme might not work very well for you.

Instead, you should know the size of the stream up-front, and send a byte count first, followed by the data. The receiving end can then read the byte count, followed by that many bytes of data.

If you want to allow clients to connect "at any time" then you probably want to packetize your stream in multiple packets, each of which is smaller, and each of which has a leading byte count. You could make the rule that a byte count of 0 means "end of stream". When someone connects, they''ll start receiving whole packets from wherever they''re starting, each of which has a length, followed by that amount of data.

Share this post


Link to post
Share on other sites

  • Advertisement