Newsgroups : Borland : borland.public.delphi.internet.winsock : 2006 Dec : Re: How to prevent exception messages being shown in FTP client application & FT

www.cryer.info
Managed Newsgroup Archive

Re: How to prevent exception messages being shown in FTP client application & FT

Subject:Re: How to prevent exception messages being shown in FTP client application & FT
Posted by:"Remy Lebeau (TeamB)" (no.spam@no.spam.com)
Date:Wed, 27 Dec 2006 11:17:58

"Venkatesh VT" <venks@vsnl.com> wrote in message
news:45929220@newsgroups.borland.com...

> When ever the internet connection is broken it redials through RAS to
> connect to connect to the internet.I find that an exception dialog is
> shown with a message' 'Socket error #10051.Connection is reset by peer'

That is normal behavior for TCP.  Your connection was abnormally lost.  When
the connection is reestablished, the remote machine reports back to your
machine that the socket stack on the remote machine has been reset.  The
only thing you can do is wrap the Connect() is a try..except block and try
again.

> How do I prevent the message from displaying at all.(I am using try
> ..finally so that the program continues to run inspite of the Exception
> messages)

A try..finally block does not catch exceptions.  It only executes the code
inside the 'finally' section and then allows the exception to continue along
the call stack.  To actually catch the exception, you need to use a
try..except block instead.

> I also would like to know what is the correct command to reinitiliase
> the socket connection when a connection is broken

There isn't any.  You have to fully disconnect and then reconnect fresh.

> I am presently using  FTP.socket.close

You should never be calling Close() directly at all.  To disconnect
properly, you should be calling TIdFTP's Quit() or Disconnect() method
instead.

> How ever this works only if there is an existing connection that
> is getting disconnected & gives an AV if there is no connection.

Exactly.  Which is why you should not be trying to access the Socket
property like you are.

> I would like to know the command which will not give an AV ,if it is
> executed with out a disconnect

Use the Disconnect() method instead.


Gambit

Replies:

In response to:

www.cryer.info
Managed Newsgroup Archive