Article View: borland.public.cppbuilder.internet.socket
Article #5752Re: Image and network problem - the answer !
From: Remy Lebeau (TeamB)
Date: Sat, 19 Jun 2004 05:57
Date: Sat, 19 Jun 2004 05:57
27 lines
2237 bytes
2237 bytes
"Patrick FAURE" <DidactSoft@aol.com> wrote in message news:40d3c8ef$1@newsgroups.borland.com... > The problem was in : > Socket->ReceiveBuf(OFFSETBYTES(DataComplete->Memory, oldSize), > incomingSize); > where the number of bytes read by ReceiveBuf is not always > equal to incomingSize. If the incomingSize is obtained via ReceiveLength() just prior to calling ReceiveBuf(), then ReceiveBuf() is guaranteed to return that many bytes in a single call, since the whole purpose of ReceiveLength() is to determine how many bytes have been received and buffered and are ready for immediate reading. The only way ReceiveBuf() could not return the full number of bytes in a single call under that scenerio is if there is an error on the socket, or maybe if there is a LOT of data buffered and the socket chooses not to return it all in a single call for whatever reason (unlikely, though). In any case, it is very common with socket programming for ReceiveBuf() to not return the full bytes in general, so you should always be taking that into account, calling ReceiveBuf() in a loop until all of the expected data has been received in full. Gambit
Technical Details
Message-ID:
<40d3d6a9$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!feeder.enertel.nl!nntpfeed-01.ops.asmr-01.energis-idc.net!216.196.110.149.MISMATCH!border2.nntp.ams.giganews.com!nntp.giganews.com!news-out.ntli.net!newsrout1.ntli.net!news-in.ntli.net!ntli.net!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<40d3c8ef$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 11508e,bc9967afc75004ef X-Google-Attributes: gid11508e,public From: "Remy Lebeau \(TeamB\)" <gambit47.no.spam@no.spam.yahoo.com> Newsgroups: borland.public.cppbuilder.internet.socket References: <40d3c8ef$1@newsgroups.borland.com> Subject: Re: Image and network problem - the answer ! Date: Fri, 18 Jun 2004 22:57:09 -0700 Lines: 29 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: 68.169.168.124 Message-ID: <40d3d6a9$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1087624873 68.169.168.124 (18 Jun 2004 23:01:13 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!feeder.enertel.nl!nntpfeed-01.ops.asmr-01.energis-idc.net!216.196.110.149.MISMATCH!border2.nntp.ams.giganews.com!nntp.giganews.com!news-out.ntli.net!newsrout1.ntli.net!news-in.ntli.net!ntli.net!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail