Board index » delphi » Indy-Telnet Connection Error Handle

Indy-Telnet Connection Error Handle

Hi Everyone,

    I'm trying to use the Indy Telnet Client software, when i attempt to
connect it to a server and if the server is not available i get a except
error message "Socket Error # 10061 Connection refused.". My question is
that how or can i add my own error message handle for this? Thanks!

 

Re:Indy-Telnet Connection Error Handle


On Wed, 9 Apr 2003 01:13:46 -0700, "Dimsion" <Dims...@hotmail.com>
wrote:

Quote
>Hi Everyone,

>    I'm trying to use the Indy Telnet Client software, when i attempt to
>connect it to a server and if the server is not available i get a except
>error message "Socket Error # 10061 Connection refused.". My question is
>that how or can i add my own error message handle for this? Thanks!

You can use a try..except block for handling exceptions.

If you are only interested in socket errors, you could do something
like this:

uses IdException, IdWinsock2;

try
  IdTelnet1.Connect;
//whatever
except
    on E: EIdSocketError do begin
         // If 10038 - abort was called. Server will return 225
       case E.LastError of
          wsaeconnreset : MessageBox('There is no server on the host
machine.  Please make sure that the hostname is entered correctly.');
          wsaehostunreach : MessageBox('Can not reach host due to a
network problem.  Please check your routers and try again.');
//well, you figure out the rest
        end;
    end;
end;

The E.LastError value is usually the rror code returned from the
stack.  For Winsock, there is a reference at
http://www.sockets.com/a_c.htm .  As a partical matter, the first
errors you really should focus on are listed in the User Fixable
errors list.  Those Winsock errors are usually due to network
failures, problems with a server, stack misconfiguration, or sometimes
incorrect information entered by a user (I've done that a number of
times myself).  Most of the other errors are usually due to some type
of programming error on your part or a bug in Indy (which I hope is
not the case).

HTH.
J. Peter Mugaas - Chairperson, Distribution Team, Indy Pit Crew
Internet Direct (Indy) Website - http://www.nevrona.com/Indy
Personal Home Page - http://www.wvnet.edu/~oma00215
If I want to do business with you, I will contact you.  Otherwise, do not contact me.

Other Threads