[twsocket] TWsocketserver application - Broken link

2010-03-22 Thread Olivier BERTHELOT
Hi,

I would like to know how to detect a client's broken link in an
TWsocketserver application. Not a closed connection but really a broken one.
For exemple the BrokenLink procedure below doesn't add anything in the
Tlistbox1 when the connection is down.


**
**
TMyClient = class(TWSocketClient)
  public
RcvdLine: String;
ConnectTime : TDateTime;
UserName: String;
ComputerName: String;
OsType  : String;
  end;
**
**
public
  Procedure BrokenLink(Sender: TObject; ErrCode: Word);
**
*
*
{**}
procedure TForm1.WSocketServer1ClientCreate(Sender: TObject;Client:
TWSocketClient);
Begin
  With Client As TMyClient Do
Begin
  OnDataAvailable:= ClientDataAvailable;
  ConnectTime:= Now;
  UserName   :='Unknown';
  ComputerName   :='Unknown';
  OsType :='Unknown'
  OnSessionClosed:=BrokenLink;
End;
End;
{**}
Procedure TForm1.BrokenLink(Sender: TObject; ErrCode: Word);
Begin
   ListBox1.Items.Add('BrokenLink : '+IntToStr(Errcode));
End;
{**}


-- 
Sincerelly ,
BERTHELOT Olivier
--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] TWsocketserver application - Broken link

2010-03-22 Thread Angus Robertson - Magenta Systems Ltd
 I would like to know how to detect a client's broken link in an
 TWsocketserver application. Not a closed connection but really a 
 broken one.

An idle TCP connection does not send any data, so you will not know it's
broken until it times out failing to send data.  

You can enable keep alive to send stuff regularly and force an error. 

You always get session closed, even for a clean close or failed open so
you need to check the error number. 

Servers should also timeout idle connections, the latest wsocket has
various timers for such purposes. 

Angus

--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be