Please help debug my socket code!

Ioannis Nompelis nompelis at nobelware.com
Wed Feb 13 17:16:54 UTC 2019


Joe, is there something missing here?

You fork() a child to handle the incoming connection first. Good. The child
goes into a reactive mode, receiving several commands and responding back
with 3-letter codes and some text. Fine.

When ftp_session() gets the PASV command from the client, you
negotiate_listen() to get a new listening socket, and store the descriptor
in "pasvfd", which you they query for info for your sake.

Where is the new port that is associated with pasvfd communicated back
to the client? (This is a protocol issue.) Is it happening in line 251
here?

         fprintf(conn, "227 Entering Passive Mode %s\n", pasv_desc);

I recommend that you sit on two terminals with CURL and type in all of what
you expect of the client and talk to your server. That way you will know if
your intended behaviour is taking place from the client's perspective.
Use the first CURL session to talk to the serve() function and force the
server to enter ftp_session(). Then get to the PASV command, and from
another terminal fire up CURL to hit that new socket.



More information about the Friends mailing list