Article View: borland.public.cppbuilder.internet.socket
Article #4451Re: Error on reconnection to server
From: Remy Lebeau (TeamB)
Date: Tue, 08 Feb 2005 17:45
Date: Tue, 08 Feb 2005 17:45
46 lines
2852 bytes
2852 bytes
"Ben" <TerNOra@etraSPAMde.nl> wrote in message news:4208d668$1@newsgroups.borland.com... > I'm using a client socket in nonBlocking mode. > The data handling is done in a thread to keep track of the > not sent packages in a circular buffer and resent them on > reconnection. Threading works better if you use blocking mode instead. > I try to reconnect by setting: > if (!TCPForm->ClientSocket->Active) > TCPForm->ClientSocket->Active=true; You did not show where you are calling that from. > but this is not working secure, it takes different times to reconnect. Quite possibly, yes, especially since you are using non-blocking mode, so the socket has to process a bunch of internal window messages before the connection is fully established. > Error message generated sometimes, say one in 10 to 20 reconnections: > ESocketError, Windows SocketError, Illegal argument 10022 on API > "WSACancelASyncRequent" The only time Borland's socket components call WSACancelAsyncRequest() is when Disconnect() is called while a lookup is still in progress from a previous connect attempt. Where are you calling Disconnect() from? Most likely, Disconnect() is being called after the lookup has actually completed, but before the resulting window message has been processed. Thus, component's internal lookup handle has not been nulled yet but now points to an invalid lookup task. > This message is received sometimes at the: > if (ClientSocket->Active) > ClientSocket->Socket->SendBuf((void*)&Message,sizeof(TCPmessageType)); SendBuf() calls Disconnect() if the data fails to be sent due to a socket error. My guess would be that your threading code is not using the socket property to begin with, so your code conflicts with itself at times. Please show your actual code. Gambit
Technical Details
Message-ID:
<4208fa07$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!feeder2.on.meganewsservers.com!meganewsservers.com!textfeed1.on.meganewsservers.com!38.119.100.83.MISMATCH!news-out.nntp.be!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>Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,7304809fda7b8b4e 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: <4208d668$1@newsgroups.borland.com> Subject: Re: Error on reconnection to server Date: Tue, 8 Feb 2005 09:45:48 -0800 Lines: 48 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: <4208fa07$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1107884551 68.69.17.41 (8 Feb 2005 09:42:31 -0800) Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!feeder2.on.meganewsservers.com!meganewsservers.com!textfeed1.on.meganewsservers.com!38.119.100.83.MISMATCH!news-out.nntp.be!propagator2-sterling.newsfeeds.com!news-in.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail