πŸš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: How to reconnect a client ?

#3581
From: Denis
Date: Tue, 28 Jun 2005 15:35
102 lines
4162 bytes
I attempt to clarify.


"Hans Galema" <notused@notused.nl> a οΏ½crit dans le message de
news:42c15d78@newsgroups.borland.com...
> 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.


-----------------
both TclientSocket and TServerSocket are non blocking.
each program have one TServeurSocket and 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?
>

---------------
a connection 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 ?

---------------
So what can I do to reconnect it ?
When can I do that ? ( must I wait some seconds ? )
Where ? More precisely in what part of the handler can I do that ?
can I process in a ClientSocket1Error handler ? or ClientSocket1Disconnect ?
---------------


>
> > 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:

--------------
Sorry, you are right.
-------------

If the handler is OnS
>
> 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.

--------------
Hummm... so I have to try to reconnect outside all the event handlers ?

It's damage because the socket is know inside the event handler.

So if I understand correctly I have to maintain a list of all my clients and
build a loop to check connection every 'n' seconds in a timer function ?
that right ?

But I don't know what I have to check. The property "Active" of the
TClientSocket ? ( I have not acces to the TCustomWinSocket* provide in
handler ? )


-Denis.
Technical Details
Message-ID: <42c16e39$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!proxad.net!212.101.4.254.MISMATCH!solnet.ch!solnet.ch!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <42c15771@newsgroups.borland.com> <42c15d78@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,274cba0e00c4db70
X-Google-Attributes: gid11508e,public
X-Google-Language: ENGLISH,ASCII
Reply-To: "Denis" <d.martinez@lac-sofreltc.fr>
From: "Denis" <d.martinez@lac-sofreltc.fr>
Newsgroups: borland.public.cppbuilder.internet.socket
References: <42c15771@newsgroups.borland.com> <42c15d78@newsgroups.borland.com>
Subject: Re: How to reconnect a client ?
Date: Tue, 28 Jun 2005 17:35:15 +0200
Lines: 104
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: 81.80.234.43
Message-ID: <42c16e39$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1119972921 81.80.234.43 (28 Jun 2005 08:35:21 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!proxad.net!212.101.4.254.MISMATCH!solnet.ch!solnet.ch!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail