|Subject:||Re: Connected method shows connection when I don't expect one (Indy 10.0.52)|
|Posted by:||Remy Lebeau (Indy Team) (email@example.com)|
|Date:||Mon, 28 Aug 2006|
"Mark McLain" <mmcla…@rallansci.com> wrote in message
> I recently migrated an old FTP client program that used the NetMasters
> NMFTP library in Delphi 5 to the TIdFTP class from Indy 10.0.52.
That is an old version of Indy. The current snapshot is 10.1.5. You should
> My problem is that I am intermittently (< 1% of the time) seeing
> situations where the "Connected" method reports a connection
> when I don't expect a connection to be present.
You likely still have unread data stored in the connection's InputBuffer
property. Indy considers a connection active while there is enough cached
data in the InputBuffer to satisfy reading operations, even after the
connection has been closed. This is important for protocols like HTTP where
the sender may close the connection immediately after sending the data but
before the receiver has a chance to receive it all.
> For example, after I am done with a host, I execute the "Quit" method
> which I understand should be calling the "Disconnect" method. I then
> execute the "Connected" method
Why are you calling Connected() after calling Quit()? Quit() closes the
connection, so the connection will always be disconnected.
> it indicates a connection remains.
> I then explicitly execute the "Disconnect" method and call the
> "Connected" method again; it still indicates a connection remains.
Disconnect() does not clear the InputBuffer.
> I have added some logging code to the "OnDisconnect" event handler
> and it seems to fire one-time-only, at the time of the first Quit.
As it should be.
> One other observation that may be relevant
It is not.
> I have done a "netstat -an" and observed that this second program seems
> to leave ftp sessions hanging. For example, this second program can be
> at a point in its execution where all ftp sessions should be closed, and
> "netstat -an" will still show approximately 10 open ftp connections.
When an application closes a socket, the OS itself keeping the socket open
in the background for an extended period of time to ensure that all pending
data is removed from the network. From the application's perspective, the
socket is no longer accessible, but the OS is still using it.
> Is it possible that one application is interfering with the other
Connected method shows connection when I don't expect one (Indy 10.0.52) posted by Mark McLain on Mon, 28 Aug 2006