Article View: borland.public.cppbuilder.internet.socket
Article #4355Re: (code) Re: Error on reconnection to server
From: Hans Galema
Date: Tue, 15 Feb 2005 13:23
Date: Tue, 15 Feb 2005 13:23
36 lines
2303 bytes
2303 bytes
Ben wrote:
> int TTCPForm::TCPClientSocketSend(TCPmessageType Message)
Where and when are you calling this function ?
> try
> {
> ClientSocket->Socket->SendBuf((void
> *)&Message,sizeof(TCPmessageType));
int nbytessent = ClientSocket->Socket->SendBuf((void
*)&Message,sizeof(TCPmessageType));
You are not checking the return value of SendBuf(). It returns
the amount of bytes actually sent. Check and resend if needed.
> void __fastcall TTCPForm::ClientSocketRead(TObject *Sender,
> TCustomWinSocket *Socket)
> {
> int NmbrOfBytes;
> try
> {
> NmbrOfBytes=Socket->ReceiveBuf((void
> *)&RxMessage,sizeof(TCPmessageType));
You are not supposed to read as much bytes as you want. First check
Socket_ReceiveLength() and only read as much bytes as ReceiveLength()
indicates. If not all bytes are there then buffer them and wait for the
next OnRead event.
Is it possible in your program that SendBuf() and ReceiveBuf()
are used in such a way that if data is already send where not all data
came in yet ?
Hans.
Technical Details
Message-ID:
<4211f823@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!newsread.com!news-xfer.newsread.com!news-out.newsgroups.com!propagator2-sterling.newsfeeds.com!news-in.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mailReferences:
<4208d668$1@newsgroups.borland.com> <4208fa07$1@newsgroups.borland.com> <4209bc24$1@newsgroups.borland.com> <42105bd0$1@newsgroups.borland.com> <4210767f$1@newsgroups.borland.com> <4211e9a4$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,7304809fda7b8b4e X-Google-Attributes: gid11508e,public X-Google-Language: ENGLISH,ASCII-7-bit Date: Tue, 15 Feb 2005 14:23:23 +0100 From: Hans Galema <notused@notused.nl> User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: borland.public.cppbuilder.internet.socket Subject: Re: (code) Re: Error on reconnection to server References: <4208d668$1@newsgroups.borland.com> <4208fa07$1@newsgroups.borland.com> <4209bc24$1@newsgroups.borland.com> <42105bd0$1@newsgroups.borland.com> <4210767f$1@newsgroups.borland.com> <4211e9a4$1@newsgroups.borland.com> In-Reply-To: <4211e9a4$1@newsgroups.borland.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 129.125.201.248 Message-ID: <4211f823@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1108473891 129.125.201.248 (15 Feb 2005 05:24:51 -0800) Lines: 36 Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!newsread.com!news-xfer.newsread.com!news-out.newsgroups.com!propagator2-sterling.newsfeeds.com!news-in.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail