Back when .NET Framework 1.0 was launched, there were no good FTP client implementations available for .NET so I wrote my own implementation using System.Net.Socket. Recently I had to make some changes to it, and while debugging I noticed garbled output from the IIS 5.1 FTP server I'm testing against (WinXP SP 2) when closing the connection.
The communication goes like this:
Send: QUIT<CRLF>
Receive: 221<CRLF><NUL>?<ETX><NUL>
(socket closed)
The FTP command channel handler is line-oriented using CRLF as terminator, and upon receiving the four bytes after the first CRLF it waits for a second CRLF causing a timeout error. The entire sequence is returned by a single socket read operation, and I've verified that the byte count returned from the socket is correct.
This sequence of bytes has been consistent against this server and I was wondering if this is expected/ can be prevented, or if I should simply "quick fix" it adding it to my list of "MS FTP Server quirks".