简体   繁体   中英

How do I use PORT ftp raw command in c#?

I am trying to make a FTP client in c#. I found a class that support basic FTP commands on http://msdn.microsoft.com/en-us/library/system.net.webrequestmethods.ftp_members.aspx .

on the list, PORT command is missing.

How do I use PORT command in c#?

At first thought, I imagine that you specify the port in the URI that you use to connect:

ftp://user:password@ftp.somesite.com:1234/

I know this doesn't encompass the entire functionality of the PORT command, but it's a start.

Have you looked at the FtpWebRequest class? It is designed for FTP, rather then the general WebRequest class.

You can set the overriden Method property to PORT if needed.

Download, upload, append and list will do the PORT command for you automatically when negotiation endpoints. Unless you are writing your own FTP client you should not need to use this command.

In active mode, the FTP server will connect to the client machine, and your PORT command needs to specify a port number the FTP server can connect to.

In passive mode, you connect to the FTP server. When you send the PASV command, the FTP server will respond with an address and port number you can connect to.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM