Question

We all know that .Net has ftp related classes and i have often saw people always use few property of ftp called:

wrq.KeepAlive = false;
wrq.UseBinary = false;
wrq.UsePassive = true;

Can anyone tell me what is the meaning of KeepAlive, UseBinary & UsePassive?

What will happen when we set true or false for the above property, specifically tell me what is the usage or meaning of UsePassive property.

One person explain briefly about passive mode :-

UsePassive:
false if the client application's data transfer process listens for a connection on the data port; otherwise, true if the client should initiate a connection on the data port. The default value is true

the above answer is not very clear to me. so anyone can explain about Passive mode in more details....thanks

Was it helpful?

Solution

Maybe these MSDN articles can help you?

KeepAlive

Gets or sets a Boolean value that specifies whether the control connection to the FTP server is closed after the request completes.

When the KeepAlive property is set to false, the control connection is closed when you call the Close method.

Changing KeepAlive after calling the GetRequestStream, BeginGetRequestStream, GetResponse, or BeginGetResponse method causes an InvalidOperationException exception.

http://msdn.microsoft.com/en-us/library/system.net.ftpwebrequest.keepalive.aspx


UseBinary

Gets or sets a Boolean value that specifies the data type for file transfers.

If you are sending binary data, such as an image, set this property to true. If you are sending text, set the property to false. Specifying true causes the FtpWebRequest to send a "TYPE I" command to the server. Specifying false causes the FtpWebRequest to send a "Type A" command to the server. FTP servers can ignore these commands.

Changing UseBinary after calling the GetRequestStream, BeginGetRequestStream, GetResponse, or BeginGetResponse method causes an InvalidOperationException exception.

http://msdn.microsoft.com/en-us/library/system.net.ftpwebrequest.usebinary.aspx


UsePassive

Gets or sets the behavior of a client application's data transfer process.

Setting the UsePassive property to true sends the "PASV" command to the server. This command requests the server to listen on a data port and to wait for a connection rather than initiate one upon receipt of a transfer command.

For a description of the behaviors that are specified using UsePassive, see RFC 959, "File Transfer Protocol," Section 3.2, "Establishing Data Connections" and Section 4.1.2, "Transfer Parameter Commands," available at http://www.rfc-editor.org/.

Changing UsePassive after calling the GetRequestStream, BeginGetRequestStream, GetResponse, or BeginGetResponse method causes an InvalidOperationException exception.

If UsePassive is set to true, the FTP server may not send the size of the file, and download progress can always be zero. If UsePassive is set to false, a firewall can raise an alert and block the file download.

http://msdn.microsoft.com/en-us/library/system.net.ftpwebrequest.usepassive.aspx

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top