What port does My.Computer.Network.UploadFile work on?

  • Thread starter Thread starter Jerry Spence1
  • Start date Start date
J

Jerry Spence1

I have a program (VB2005) which uses
My.Computer.Network.UploadFile(Filename, "ftp://Host/inbox/" & Filename,
<Username>, <Password> False, 10000)

to upload a file from a distant PC to my PC and this works OK, providing
that I open out the firewall on my router to allow ALL incoming ports.

I thought the above this worked on ftp and so I opened up port 21 and that
doesn't seem to be sufficient. When I put a network analyser trace on, it
seems to set up the original connection handshaking using port 21, but once
the data starts to flow, a complete random number of ports seem to be used.

This program will be used in a commercial environment and I need to know how
to configure the customer's routers to allow it to happen.

Has anyone met this before? I can't seem to find much on the Internet about
it.

-Jerry
 
That's the way ftp works. The control channel is on port 21. This is
where all the communication takes place between the client and server.

When you do a directory listing or upload/download a file, the client
tells the ftp server to connect to the client on another port chosen by
the client. The client then listens on that port and waits for the
server to connect and send the data. This is active mode.

Passive mode usually works for clients that are behind firewalls. In
passive mode, it is the server who chooses the data channel (port) and
tells the client to connect on that port. The server waits for the
client to connect on that port and when the connection is made, the
server sends the data.

When the data has been sent, the data channel is closed.

I've never used My.Computer.Network.UploadFile, but I have used
System.Net.WebClient. Here's an example:

Dim ftpc As New WebClient
ftpc.Credentials = New NetworkCredential(UID, PWD)
ftpc.DownloadFile("ftp://pub/file.zip","d:\temp\file.zip")
ftpc.Dispose()
 
Terry Olsen said:
That's the way ftp works. The control channel is on port 21. This is
where all the communication takes place between the client and server.

When you do a directory listing or upload/download a file, the client
tells the ftp server to connect to the client on another port chosen by
the client. The client then listens on that port and waits for the
server to connect and send the data. This is active mode.

Passive mode usually works for clients that are behind firewalls. In
passive mode, it is the server who chooses the data channel (port) and
tells the client to connect on that port. The server waits for the
client to connect on that port and when the connection is made, the
server sends the data.

When the data has been sent, the data channel is closed.

I've never used My.Computer.Network.UploadFile, but I have used
System.Net.WebClient. Here's an example:

Dim ftpc As New WebClient
ftpc.Credentials = New NetworkCredential(UID, PWD)
ftpc.DownloadFile("ftp://pub/file.zip","d:\temp\file.zip")
ftpc.Dispose()

Thanks for that Terry.

I guess the question now is "How do I get My.Computer.Network.UploadFile to
work in Passive mode?"

-Jerry
 
Back
Top