🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.internet.socket
Article #3580

Re: How to reconnect a client ?

#3580
From: Hans Galema
Date: Tue, 28 Jun 2005 14:20
54 lines
2890 bytes
Denis wrote:

> I'm using many non-bloquing application with TServerSocket and
> TClientSocket.

Now which one is non-blocking ? Both ?

> There is many executable who are both client and servers. 

Please clarify:
There are more instances of your program. Each program has more than one
TServerSocket and more then one TClientSocket.

> At time 't' an application is server with 'n' client connected. In the same
> time this application is also a client connected to one or more servers.
> 
> My question: What exactly must i do when a client connection is broken ? 

Now which connection are you referring to ? A connection belonging to the
TServerSocket or to the TClientSocket?

> The
> socket is unusable and unable to reconnect to the server.
> So I must delete it and create a new client socket to lookup again the
> server.

So it was a clientconnection from you TClientSocket ? Of course
the TClientSocket can reconnect. Why not ?

> What is the right way, and the order, to process ??
> This a part of code that do actually this. ( this a client part ) is it
> correct ?
> 
> void __fastcall client::ServerError(TObject *Sender, TCustomWinSocket
> *Socket, TErrorEvent ErrorEvent, int &ErrorCode)

Please do not change the name of eventhandlers. I do not know about
'ServerError'. What exists though for TClientSocket is:

void __fastcall TForm1::ClientSocket1Error(TObject *Sender,
	  TCustomWinSocket *Socket, TErrorEvent ErrorEvent, int &ErrorCode)

> void __fastcall client::ServerDisconnect (TObject *Sender, TCustomWinSocket
> *Socket)

Do you mean for TClientSocket ?:
void __fastcall TForm1::ClientSocket1Disconnect(TObject *Sender,
		 TCustomWinSocket *Socket)

Think that it is not needed to delete the old and create a new
TClientSocket. But indeed you cannot reconnect in the same eventhandler.
Start a TTimer and reconnect in the TTimer eventhandler.

Hans.
Technical Details
Message-ID: <42c15d78@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!news-out.nntp.be!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail
References: <42c15771@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,274cba0e00c4db70
X-Google-Attributes: gid11508e,public
X-Google-Language: ENGLISH,ASCII-7-bit
Date: Tue, 28 Jun 2005 16:20:06 +0200
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: How to reconnect a client ?
References: <42c15771@newsgroups.borland.com>
In-Reply-To: <42c15771@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: <42c15d78@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1119968632 129.125.201.248 (28 Jun 2005 07:23:52 -0700)
Lines: 54
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!news-out.nntp.be!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail