🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.internet.socket
Article #1134

Re: Why would the socket not receive all the data?

#1134
From: Remy Lebeau (TeamB)
Date: Sun, 25 Mar 2007 22:56
47 lines
2487 bytes
"Paul at NCF" <notplmacca@clara.co.uk> wrote in message
news:4606d0c4$1@newsgroups.borland.com...

> Why would the reading/receive not recieve all the data in one go?
> ie. why does the read need to be in a loop?

Because the socket's internal receive buffer may not have enough room
to hold all of the inbound data at one time.  Also, network latency
can cause the socket to timeout internally and return whatever is
currently in its buffer even if it isn't completely full yet.

> Ditto write/sending?

Same thing with the internal send buffer.  It may not have enough room
to hold all of the outbound data at one time.

> Is it to do with the WinSock layer?

Yes.

> If the data is sent or received in small chunks, are they random in
size
> or meaning

No.

> are they really based on some low level protocol packet (ethernet or
IP, TCP, etc)?

That is part of it.  The ethernet layer does try to send/receive
packets as efficiently as it can.  So there is a balancing act between
the size of the data inside each packet, and how each packet is
transmitted/received.

> 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).

The only way that can happen is if you have multiple threads writing
to, or reading from, the same socket at the same time without
serializing their access to the socket to prevent concurrent
operations.


Gambit
Technical Details
Message-ID: <4606f07a$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!nx02.iad01.newshosting.com!newshosting.com!203.109.252.33.MISMATCH!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail
References: <4606d0c4$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,56c8fbfda2c57917
X-Google-Attributes: gid11508e,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Remy Lebeau \(TeamB\)" <no.spam@no.spam.com>
Newsgroups: borland.public.cppbuilder.internet.socket
References: <4606d0c4$1@newsgroups.borland.com>
Subject: Re: Why would the socket not receive all the data?
Date: Sun, 25 Mar 2007 14:56:35 -0800
Lines: 49
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1409
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409
NNTP-Posting-Host: 75.83.34.171
Message-ID: <4606f07a$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1174859898 75.83.34.171 (25 Mar 2007 14:58:18 -0800)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!nx02.iad01.newshosting.com!newshosting.com!203.109.252.33.MISMATCH!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail