Winsock EOF msg?
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.
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
Popular Topics
Advertisement
Recommended Tutorials
Advertisement