Handle an unexpect disconnection from the server

Nov 14, 2011 at 9:34 AM

I need to handle an unexpect disconnection from the server.

I'm building the instance of the client with this code

new FtpClient(string.Empty, string.Empty, host) { 
	DataChannelType = FtpDataChannelType.Active, 
	ReadTimeout = 2000, 
	WriteTimeout = 2000 
};

but I can't get an error if I run a download command and after a second I shutdown my FTP server.

Any suggestion ?

Many thanks,

claudio

Coordinator
Nov 15, 2011 at 1:16 AM

I'll look into it, but so you know there is no way to know if the connection has been lost without reading or writing to the socket, i.e., just because the connection was unexpectedly lost and the client is sitting idle doesn't mean the client knows the connection has been lost until it attempts to read or write to the socket.