The question is to get a list of ftp server directories ... So far I have not managed to get anything ...

Sending:

send(S,"LIST\r\n",strlen("LIST\r\n"),0); 

Comes

150 Opening ASCII mode data connection for / bin / ls.

226 Transfer complete. 8a232 bytes transferred. 8.04 KB / sec.

What did he send me? ( Transfer complete ... ) I got nothing ... How can I get this list of directories \ files?

  • FTP has two working ports - the manager and for data transfer. You send commands to the manager, you read the execution status from him, and the data itself must be read from the data transfer port. - uilenspiegel
  • Those. Do I need to create an additional connection ... an additional socket connected to the new port? And where is the port of communication and data acceptance (p1, p2)? I generally connect to the 21 port ... PORT. The command assigns the address and port of the host to be used as an active participant in the connection over the data link. The command arguments are a 32-bit IP address and a 16-bit connection port number. These values ​​are divided into six 8-bit fields and are presented in decimal form: h1, h2, h3, h4, p1, p2, where hN are address bytes (from high to low) and pN are port bytes (from high to low) . - Alerr

1 answer 1

The 21st port is the control port of the server. Obtaining a port number for data depends on whether the client is active in the active mode — active or passive. If after connecting to the 21st server port, the client decides to work in active mode, then it sends the PORT command to the server, the parameters of which are the client's IP address and the port number on which the client will wait for a connection from the server. If the client wants to work in the passive mode, he sends the PASV command, in response to which the server sends the port number of the server to which the client should connect to exchange data. Those. in active mode, the second connection is created by the server, and in the passive mode, the client.

  • It is clear, but how to get this list? in the form of data? I have a pasv connection ... Can you provide a link in the network to a normal ftp + Winsock example? It’s not clear how to get data on the second socket ... Will they come after the request?))) - Alerr