I am writing another ftp client (just what the world needs :) ).
I have run across something I don't understand. If I connect
to a Windows server, everything seems to work properly. But
if I connect to a Unix server, I never get a 226 Transfer Complete
message after I get the LIST(ing). I do get a FD_CONNECT on the
"data" port, the directory listing (FD_READ), and a FD_CLOSE on the
"data" port. But no response on the "main" port.
I see that the Windows server responds to LIST with 125 and the
Unix server responds with 150. Could anyone help set me straight ?

Output from my program:


Connected to <ftp.microsoft.com>
220 Microsoft FTP Service
USER anonymous
331 Anonymous access allowed, send identity (e-mail name) as password
PASS [email]user@the.net[/email]
230-This is FTP.Microsoft.Com.
230 Anonymous user logged in.
SYST
215 Windows_NT
REST 0
350 Restarting at 0.
PWD
257 "/" is current directory.
TYPE A
200 Type set to A.
PASV
227 Entering Passive Mode(207,46,133,140,52,191).
LIST
125 Data connection already open; Transfer starting.
226 Transfer complete.

Connected to <ftp.kpn.be>
220-**
220-** Login as "anonymous" with your e-mail address as password
220-**
220-
220 KPN ftp server ready.
USER anonymous
331 Guest login ok, send your complete e-mail address as password
PASS [email]user@the.net[/email]
230-
230-Welcome to the KPN Belgium ftp server
230-there are currently 5 users connected in your class.
230-maximum number of allowed connections in your class 300
230-
230-We also have a WWW information server running at : [url]http://www.kpn.be/[/url]
230-
230-We also have tucows mirrors running at :
230-http://tucows.kpn.be/ - Windows software
230-http://Linuxberg.kpn.be/ - Linux software
230-http://PDACentral.kpn.be/ - Software for your PDA
230-
230-All connections, commands and transfers are logged.
230-
230-do not use ftp clients that open multiple connections
230-it will result in your IP being banned.
230-
230-
230-if you have problems with this server,
230-send your questions to: [email]ftpmaster@kpn.be[/email]
230-
230-
230 Guest login ok, access restrctions apply.
SYST
215 UNIX Type: L8
REST 0
352 Restarting at 0. Send STORE or RETRIEVE to initiate transfer.
PWD
257 "/" is current directory.
TYPE A
200 Type set to A.
PASV
227 Entering Passive Mode(193,74,22,160,93,212)
LIST
150 Opening ASCII mode data connection for /bin/ls.
Posted on 2003-02-09 12:48:50 by anon
I had the same problem, in my case I forgot to closesocket on the data-socket when getting FD_CLOSE on data port.
try that if you did forget it.

My guess this happens is because the unix-server close it's connection by

shutdown ( sock, SD_SEND ) on the data socket (which will produce FD_CLOSE in the windows client-app)
And then the server does a recv on the socket until it returns 0, to receive any data
still sitting on the socket.
The recv call blocks, until the client-side has made a closesocket() on it's data socket,
which will send an acknowledge-packet to the server which makes the blocking recv return 0.

So the server just blocks on the recv, and thus not able to send the control message on the main port.
Posted on 2003-02-10 08:33:16 by david
:alright: Thanks David :alright:
You were right about closing the socket on the data port
Posted on 2003-02-10 20:52:04 by anon