Hi
I hope someone can help me with this problem.
When I close the connection by calling Quit(),
sometimes I get an IOException when the control socket tries to flush its output stream. My theory is that it seems the server has already closed the connection. This code is in a try, finally block, so it still cleans up, but this exception is not handled anywhere and propagates up to my code.
I can do this:
try{ myftpClient.Quit() }
catch(IOException) {}
But I'm wondering if there's a better way.
Here's the exception text:
System.IO.IOException: Unable to write data to the transport connection. ---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host
at System.Net.Sockets.Socket.Send(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
at System.Net.Sockets.NetworkStream.Write(Byte[] buffer, Int32 offset, Int32 size)
--- End of inner exception stack trace ---
at System.Net.Sockets.NetworkStream.Write(Byte[] buffer, Int32 offset, Int32 size)
at System.IO.StreamWriter.Flush(Boolean flushStream, Boolean flushEncoder)
at System.IO.StreamWriter.Flush()
at EnterpriseDT.Net.Ftp.FTPControlSocket.SendCommand(String command)
at EnterpriseDT.Net.Ftp.FTPClient.Quit()
Also, sometimes I get this exception on Quit(), during the ReadReply:
System.IO.IOException: Unable to read data from the transport connection. ---> System.Net.Sockets.SocketException: Overlapped I/O operation is in progress
at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
--- End of inner exception stack trace ---
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
at System.IO.StreamReader.ReadBuffer()
at System.IO.StreamReader.ReadLine()
at EnterpriseDT.Net.Ftp.FTPControlSocket.ReadReply()
at EnterpriseDT.Net.Ftp.FTPControlSocket.SendCommand(String command)
at EnterpriseDT.Net.Ftp.FTPClient.Quit()
Thanks,
Le