Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

windows sockets: sent 2 packets, receive 1

17 views
Skip to first unread message

GilNajera

unread,
Jan 14, 2011, 10:29:45 AM1/14/11
to
Hi everyone!

I have an application that communicates 2 computers using tcp sockets
(winsocks). The most of the time it works fine, but some packets are
received as 1 when they was sent as 2 or 3. I mean, I execute two or
three send commands and receive all the data in one single packet.

The packets are sent every 200 ms (Naggle algorithm is disabled) and
there is an independent thread receiving on the other side's
application. When a packet is received it is processed immediately,
after that, the receiving is resumed.

I'm not an expert in networking, can anybody tell me why is this
happening, and how can I solve it.

Thanks in advance.

GilNajera

unread,
Jan 14, 2011, 4:15:26 PM1/14/11
to
Solved!

I understand now, I need to add some separation algorithm for all data
I receive. I will add size information to each send and re-form the
packets when data is received.

TCP has a constant flow of data, not a packet structure.

GilNajera

unread,
Jan 17, 2011, 3:50:29 PM1/17/11
to
Solved!

The first 2 characters in every 'send' are the size of data.

If received size is greater than expected size, I make a loop to
process each received block. If the las block is incomplete, another
recv is done and when that block is complete, it is processed.

Thank you all!

0 new messages