How to implement PASV mode (server side)

How do I create a server that accepts PASV mode connections?

Date Entered: 10/8/2001    Last Updated: 10/8/2001

This is what you have to do to implement passive mode on the server side:

1. Listen for the PASV command from the client

2. Decide what port you will be listening to for the data connection

3. Respond with "227 Entering passive mode (IP,X,Y)"

IP = your IP address separated by commas, i.e. "127,0,0,1"

The client interprets x and y as the port number to connect to like this

x*256 + y = port number

so: "227 Entering passive mode (127,0,0,1,4,61)" would tell the client that the server is listening on port 1085

The port number must be different for every clients connection. To do this you will have to dynamically instantiate a new IPDaemon and have it listen on that port.

4. Once the client connects you should push the data through IPDaemon to the client and disconnect when the transfer is finished.

You should chose a round robin of port numbers to listen to, maybe 1024 to 3000. When you reach 3000 start back at 1024.


We appreciate your feedback.  If you have any questions, comments, or suggestions about this entry please contact our support team at kb@nsoftware.com.