Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
3k views
in .NET FTP by (51.1k points)
A user of edtFTPnet/Free writes (highlighting added by me):
I downloaded the EdtFtpNet source code from the internet and it seems that the source code never notifies me when the FTP is closed on the server's end. I added event handlers for the code Closed , Closing, and ReplyReceived notifications but they never were called. The IsConnected method even said the connection was open. What I did I connected to and FTP server on the internet and just left the connection open. I wanted to see how long the connection would stay open till the server closed the connection. I left the connection open for about two hours and then when I tried to change directories on the server after that two hours you code threw an exception saying the conncection was closes. connection was closed by the server but your code never notified me that the connection was closed and the IsConnected method said the connection method was open even when it was not.


TCP/IP only detects connection problems when a transmission is attempted. In FTPConnection no polling of the connection occurs unless you explicitly implement it. FTPConnection doesn't try to send or receive any data unless you ask it to, so no transmissions are attempted unless you specifically attempt an operation. The behaviour that you are describing is therefore as is expected. What you need to do is perform an operation at regular intervals while the connection is idle. Since you don't really want to change anything, it's a good idea to call something like FTPConnection.GetSystemType(), which will cause a communication with the server without actually doing anything. If the connection is no longer valid then this will throw an exception at which point you should call Close(true) and the Connect() if you want to reconnect.

IsConnected only returns the state of the socket. It doesn't contact the server so if the last transmission was successful then it won't report an error.

FYI, the main class of edtFTPnet/PRO, SecureFTPConnection, polls the server automatically and will therefore detect disconnections by itself and trigger events as you expected, but in the free version you need to do this yourself.

- Hans (EnterpriseDT)

Please log in or register to answer this question.

Categories

...