Hi,

I am trying to make an FTP server. I am having some problems
with this, however. Actually I have 2 problems at this time.

My first problem is (really a math problem I guess):

When a client connects it sends the PORT command to establish a data socket connection. Now, the client
sends it's IP and the port it's listening on in a format
that I don't understand: it sends a string like:

PORT 102,32,69,120,15,208

where the first 4 numbers (102,32,69 and 120) form the
IP address, and the last 2 (15,208) from the port.

Now, how do I find out what the port number is?

perhaps these hints will help:
------------------------------------------------------
DATA PORT (PORT)

The argument is a HOST-PORT specification for the data port
to be used in data connection. There are defaults for both
the user and server data ports, and under normal
circumstances this command and its reply are not needed. If
this command is used, the argument is the concatenation of a
32-bit internet host address and a 16-bit TCP port address.
This address information is broken into 8-bit fields and the
value of each field is transmitted as a decimal number (in
character string representation). The fields are separated
by commas. A port command would be:
PORT h1,h2,h3,h4,p1,p2

where h1 is the high order 8 bits of the internet host address.
---------------------------------------------------------


My 2nd question should be easier:

If I'm listening on a port and someone connects, then how do I find out the IP of the person connecting?


I hope someone can help me out here,
Thanks in advance,

vbDan