Board index » delphi » How to catch exceptions of TClientSocket or TServerSocket?

How to catch exceptions of TClientSocket or TServerSocket?

Hi!
Does anybody know how to catch exceptions of TClientSocket or TServerSocket
(for example if you haven't entered an ip-address and you try to connect)? I
don't need these damn messages.
But Try ... except doesn't work.
Any ideas?

Thanx
Tobias

 

Re:How to catch exceptions of TClientSocket or TServerSocket?


In article <7en72g$o...@news07.btx.dtag.de>, llue...@t-online.de says...

Quote

>Hi!
>Does anybody know how to catch exceptions of TClientSocket or TServerSocket
>(for example if you haven't entered an ip-address and you try to connect)? I
>don't need these damn messages.
>But Try ... except doesn't work.
>Any ideas?

Write an event handler for the OnError or OnClientError event. Set the value of
ErrorCode parameter to 0 to prevent an exception from being raised:

procedure TService1.ServerSocket1ClientError(Sender: TObject;
  Socket: TCustomWinSocket; ErrorEvent: TErrorEvent;
  var ErrorCode: Integer);
begin
  ErrorCode := 0; // excxeption not raised
end;

--
Christo Crause
Thermal Separations Research
University of Stellenbosch
South Africa

Other Threads