From: Andy Baker on
I have a CE device that I need to remotely connect to my windows PC and
transfer files between them.. I already have working code on the CE devices
that I can use to transfer files to/from FileZilla server successfully but I
would like to implement some more functionality, such as verifying that the
file is valid after transfer so I am trying to code a simple Passive Mode
FTP Server in VB.NET. I have set up a TCP listener on Port 21 and my client
connects and logs in successfully, but I am having trouble with the file
transfer part. From what I understand, when the client sends a PASV command,
the server should set up a socket, send the connection information back to
the client and wait for the client to connect. I then should use a
filestream to transfer the actual file. The code I have got so far is:-

Dim p1 As Integer = 256
Dim p2 As Integer = 80

Try
'Open the correct socket here
'If the socket is valid, tell the client what to connect to
showMessage("227 Entering Passive Mode (" & DepotIPAddress & ","
& CStr(p1) & "," & CStr(p2) & ")")
Catch
End Try

Where showMessage displays the message on screen and transfers it back to
the client (this works). My plan is to open the socket, and if it fails,
increment p2 by 1 and try again until it finds a valid port, then send the
port information back to the client. DepotIPAddress contains the external IP
address of the server, separated by commas, and this also works - this is
what FileZilla sends back. Unfortunately I am getting confused with my port
numbers and have been unable to find any example code to show me how to open
the actual socket. Any assistance would be appreciated - am I even on the
right track here or is there a better way? Thanks in advance.

Andy Baker