471,325 Members | 1,269 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,325 software developers and data experts.

TCP Socket Flush

How to do a TCP socket flush in order to get the packets to their real
sizes (and not accumulate) like when we send a datagram UDP. When we
send UDP it comes with the real packet size, in other words, the packet
is sent away immediatly.

TCP accumulates. How can we send each packet individually?

Feb 2 '06 #1
3 11356
Nuno Magalhaes wrote:
How to do a TCP socket flush in order to get the packets to their real
sizes (and not accumulate) like when we send a datagram UDP. When we
send UDP it comes with the real packet size, in other words, the packet
is sent away immediatly.

TCP accumulates. How can we send each packet individually?


I believe you want to set the NoDelay socket option.

Jon

Feb 2 '06 #2
It works. Thanks.

Feb 2 '06 #3

"Nuno Magalhaes" <nu************@hotmail.com> wrote in message
news:11**********************@g43g2000cwa.googlegr oups.com...
It works. Thanks.


It works for your current circumstances:

1) If your receiver gets busy it can still read more than one "packet" at
once.
2) The internet can break up your "packet" so that less than a full packet
is received in one read.

There is no way to prevent this behaviour because TCP does not support the
concept of a "packet" therefore you should always code so as to accept TCP
data in arbitrary chunks.

Contrary to popular belief even UDP packets can be broken up - just try to
send a packet that is bigger than an ethernet frame and see what happens.
Feb 2 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Al Wilkerson | last post: by
3 posts views Thread by K Rege | last post: by
4 posts views Thread by Stephan Steiner | last post: by
15 posts views Thread by googlegroups | last post: by
reply views Thread by Mangabasi | last post: by
3 posts views Thread by A. W. Dunstan | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.