hi,

I have problem with ftp client on my computer.
In creating socket isnt any problem..send command works good a recv so..
But, when i want for example do directory list of connected ftp..
Im using LIST command..
when i will send that and next do recv function...that will return "Transfer completed"
But, where is directory list ?
How could i get this ?
thank you for everything !
Posted on 2003-07-01 16:44:05 by Marty
Did you tell the ftp-server to open another connection to send you the list with PASV before send LIST-command?
all filetransfers ( including directories ) you must do that.
Posted on 2003-07-01 18:40:49 by david
you must pardon me..i never do something with sockets

could you show me example ?
i dont know how to do that..
thx very much
Posted on 2003-07-02 16:18:52 by Marty
If I recall correct, first send the command PASV, the server will reply with something like:

227 Entering Passive Mode (210,244,168,127,10,20).

this means server opened a new socket and are waiting for you to connect to it.
Parse the reply, the first four comma-delimited numbers are the ip you should connect to with a new socket.
The last two numbers are the port you should connect to in high,low byte order.


so the ip for above reply would be 210.244.168.127
and the port number 10*256 + 20 = 2580.

Create a new socket and connect to this ip and port. When it's connected,
send on your normal socket ( the one you send commands on ) the command LIST,
and the directory should be sent to your new socket, which will be shut down by the ftp-server after you received the directory-list.
( don't forget to invoke closesocket on new socket after it is shutdown from other side, or there may be problems ).
Posted on 2003-07-02 18:44:50 by david