Article View: borland.public.cppbuilder.internet.socket
Article #1231Why would the socket not receive all the data?
From: Paul at NCF
Date: Sun, 25 Mar 2007 19:43
Date: Sun, 25 Mar 2007 19:43
45 lines
2288 bytes
2288 bytes
Hi,
Not sure if this is the right forum, but here goes. This is more fact
finding than a specific problem.
In many examples, the socket read is done by reading a length (sizeof(int))
and then reading the size of the data (length).
The sender sends the length field and the following payload data.
Both of these operations are usually done in a while loop, re-sending and
re-receiving based on the return value (size read).
My questions are:
1) Why would the reading/receive not recieve all the data in one go? ie.
why does the read need to be in a loop?
2) Ditto write/sending?
3) Is it to do with the WinSock layer?
4) If the data is sent or received in small chunks, are they random in size
or meaning, or are they really based on some low level protocol packet
(ethernet or IP, TCP, etc)?
Reason for asking is that we have recently come across problems on some of
our equipment where one message appears to be part recieved, and then
another message is overlaid on top of it (half way through). eg.
Normally:
a55a, length field, payload number of bytes msg1
a55a, length field, payload number of bytes msg2
....
Sometimes we are seeing:
a55a, length field, some bytes, a55a, length field, some of msg 2
payload (up to length of msg1)
Help appreciated.
Regards,
Paul
Technical Details
Message-ID:
<4606d0c4$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newscon02.news.prodigy.net!prodigy.net!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Thread: 11508e,56c8fbfda2c57917,start X-Google-Attributes: gid11508e,public X-Google-Language: ENGLISH,ASCII-7-bit From: "Paul at NCF" <notplmacca@clara.co.uk> Newsgroups: borland.public.cppbuilder.internet.socket Subject: Why would the socket not receive all the data? Date: Sun, 25 Mar 2007 20:43:08 +0100 Lines: 47 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.3028 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3028 NNTP-Posting-Host: 86.149.50.33 Message-ID: <4606d0c4$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1174851780 86.149.50.33 (25 Mar 2007 12:43:00 -0800) Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newscon02.news.prodigy.net!prodigy.net!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail