Article View: borland.public.cppbuilder.internet.socket
Article #2893Re: TClientSocket won't disconnect safely from TServerSocket
From: Hans Galema
Date: Thu, 05 Jan 2006 09:49
Date: Thu, 05 Jan 2006 09:49
47 lines
2238 bytes
2238 bytes
Maurice Anderson wrote:
> ..If I force a close on the server, then I get a Dr. Watson error.
How do you force a close ? Dr Watson error ?
The server can determine when a client disconnects. This is after WaitForData
returns true and a successive Read returns 0.
> Here is my code in my TServerClientThread thread's Execute function:
>
> void __fastcall TMyServerThread::ClientExecute(void)
>
> {
> try
> {
> pStream = new TWinSocketStream(ClientSocket, 6000);
> }
> catch (const Exception &E)
> {
> HandleException();
> }
>
> //BinaryTransfer1->ServerClientWinSocket = ClientSocket;
>
> while (!Terminated ||ClientSocket->Connected)
> {
> if (pStream->WaitForData(6000))
> {
int n_read = pStream->Read ( ... );
if ( n_read == 0)
ClientSocket->Close();
> }
>
> }
> }
>
> This is my client's code:
>
> void __fastcall TForm1::ServerSocket1GetThread(TObject *Sender,
> TServerClientWinSocket *ClientSocket, TServerClientThread
> *&SocketThread)
That does not very much look like client code.
Hans.
Technical Details
Message-ID:
<43bceb9d$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news3.google.com!news2.volia.net!news.germany.com!feeder.xsnews.nl!news-out.newsgroups.com!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mailReferences:
<43bcd080$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,3093e14c422eb03f X-Google-Attributes: gid11508e,public X-Google-Language: ENGLISH,ASCII-7-bit Date: Thu, 05 Jan 2006 10:49:08 +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: TClientSocket won't disconnect safely from TServerSocket References: <43bcd080$1@newsgroups.borland.com> In-Reply-To: <43bcd080$1@newsgroups.borland.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 145.98.201.248 Message-ID: <43bceb9d$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1136454557 145.98.201.248 (5 Jan 2006 01:49:17 -0700) Lines: 47 Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news3.google.com!news2.volia.net!news.germany.com!feeder.xsnews.nl!news-out.newsgroups.com!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail