Advertisement

Winsock EOF msg?

Started by April 14, 2004 11:43 AM
0 comments, last by C0UNT Z3R0 20 years, 9 months ago
Edited [edited by - C0UNT Z3R0 on April 16, 2004 6:40:04 AM]
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.
enum Bool { True, False, FileNotFound };

This topic is closed to new replies.

Advertisement