Article View: borland.public.cppbuilder.internet.socket
Article #4272Re: TClientSocket ReceiveLength() returns large value
From: Remy Lebeau (TeamB)
Date: Tue, 15 Mar 2005 23:04
Date: Tue, 15 Mar 2005 23:04
25 lines
2153 bytes
2153 bytes
"Gary Johnson" <gjohnson@cinele.com> wrote in message news:42375d21$1@newsgroups.borland.com... > on two different runs, the buffer size was 2760 and 5840 bytes. Was that much data actually being transmitted to begin with? Those look like reasonable amounts of data for socket packets. > bufferLengthInBytes = Socket->ReceiveLength(); > while(bufferLengthInBytes < Socket->ReceiveLength()) > bufferLengthInBytes = Socket->ReceiveLength(); That is not the correct way to handle things! You should only be calling ReceiveLength() *once*, and then reading however many bytes it says are actually available, and then exit the event handler, waiting for the event to be triggered again later to read more data. If you do not read a full packet, then you must buffer whatever data you did read, and then wait for the event to be triggered again to add more data to the buffer. Only process packets when your buffer contains full packets. Please go to http://www.deja.com and do a search through the newsgroup archives. Sample code for proper buffering has been posted many times before. Gambit
Technical Details
Message-ID:
<423769e3$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!proxad.net!213.200.89.82.MISMATCH!tiscali!newsfeed1.ip.tiscali.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<4235f30d@newsgroups.borland.com> <4235f764$2@newsgroups.borland.com> <42375d21$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,d813a4525d839272 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: <4235f30d@newsgroups.borland.com> <4235f764$2@newsgroups.borland.com> <42375d21$1@newsgroups.borland.com> Subject: Re: TClientSocket ReceiveLength() returns large value Date: Tue, 15 Mar 2005 15:04:47 -0800 Lines: 27 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.69.17.41 Message-ID: <423769e3$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1110927843 68.69.17.41 (15 Mar 2005 15:04:03 -0800) Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!proxad.net!213.200.89.82.MISMATCH!tiscali!newsfeed1.ip.tiscali.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail