Quick question
How can you flush the send buffer used for the sockets? Because if I want to send a message first, and listen for any recieved onces, directly after that, it'll wait for a recieved message before it sends it. EDIT : I use the sockets in C++, both for Windows and Linux.
"Take delight in the Lord and He will give you your heart's desires" - Psalm 37:4My Blog
Depending on the IO model, do not modify the buffer until after the data have been processed.
Kuphryn
Kuphryn
The TCP send buffer will be automatically flushed after some time, even if Nagle's algorithm and delayed acks are turned on. Thus, it's perfectly safe to send data, and then enter recv(), waiting for a response.
If you think the time-to-flush is too long, then you can turn on TCP_NODELAY on your socket, which means that each call to send() will result in an immediate network packet (unless the window is full).
More information can be had in the Forum FAQ and the resources it references.
If you think the time-to-flush is too long, then you can turn on TCP_NODELAY on your socket, which means that each call to send() will result in an immediate network packet (unless the window is full).
More information can be had in the Forum FAQ and the resources it references.
enum Bool { True, False, FileNotFound };
Ok, but sometimes I want to fill up a buffer before I send or sometimes I just want it to send after I say "send".
Is there no command in C++ to be able to flush that buffer manually?
Or should I implement one like this:
If the user calls the "flush" method of my Socket class, should I just set that time-to-flush to 0, wait a while (if needed) and reset to 200ms?
Is there no command in C++ to be able to flush that buffer manually?
Or should I implement one like this:
If the user calls the "flush" method of my Socket class, should I just set that time-to-flush to 0, wait a while (if needed) and reset to 200ms?
"Take delight in the Lord and He will give you your heart's desires" - Psalm 37:4My Blog
Bummer.
"Take delight in the Lord and He will give you your heart's desires" - Psalm 37:4My Blog
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement