|
From: Simon on 9 Sep 2005 12:17 Hi, I am trying to upload file from my computer to our server. Everything works as expected but I am not sure I understand the last parameter. CFtpConnection* GetFtpConnection( LPCTSTR pstrServer, LPCTSTR pstrUserName = NULL, LPCTSTR pstrPassword = NULL, INTERNET_PORT nPort = INTERNET_INVALID_PORT_NUMBER, BOOL bPassive = FALSE ); According to the doc "Specifies passive or active mode for this FTP session. If set to TRUE, it sets the Win32 API dwFlag to INTERNET_FLAG_PASSIVE. " What does it do? When I try to do OpenFile(...) when the passive == FALSE then the function hangs. If on the other hand I do exactly the same with passive==TRUE then it works like a charm. I am not using any derived classes. So what is the last flag for? And why does it hang when passive is set to false? Many thanks Simon
From: Tim Slattery on 9 Sep 2005 12:33 "Simon" <spambucket(a)example.com> wrote: >Hi, > >I am trying to upload file from my computer to our server. > >Everything works as expected but I am not sure I understand the last >parameter. > >CFtpConnection* GetFtpConnection( LPCTSTR pstrServer, LPCTSTR pstrUserName = >NULL, LPCTSTR pstrPassword = NULL, INTERNET_PORT nPort = >INTERNET_INVALID_PORT_NUMBER, BOOL bPassive = FALSE ); > >According to the doc "Specifies passive or active mode for this FTP session. >If set to TRUE, it sets the Win32 API dwFlag to INTERNET_FLAG_PASSIVE. " > >What does it do? FTP clients normally operate in active mode. In that mode, when the client wishes to transfer a file - either to send or receive a file - it tells the server that it will listen for a contact on a particular port (the client tells the server which port). The server then contacts the client on that port, and that connection is used to transfer the file. When all the data is transferred, the port is closed. In passive mode, the client asks the server to send it a port number so that it can initiate the contact. The server sends the port number and begins listening on that port. The client connects to that port, the data is transferred, and the port is closed. When you set passive to FALSE, active mode is used. The most likely reason it fails for you is that you are behind a router doing NAT (Network Address Translation). The client tells the server to contact it on some port, at the IP address assigned it by the router - which is a nonroutable address which is basically made up by the router. The server cannot make a contact on that address. In this environment you *must* use passive mode FTP, so that the client can initiate the contact. -- Tim Slattery MS MVP(DTS) Slattery_T(a)bls.gov
From: Simon on 12 Sep 2005 04:09 > > FTP clients normally operate in active mode. In that mode, when the > client wishes to transfer a file - either to send or receive a file - > it tells the server that it will listen for a contact on a particular > port (the client tells the server which port). The server then > contacts the client on that port, and that connection is used to > transfer the file. When all the data is transferred, the port is > closed. > > In passive mode, the client asks the server to send it a port number > so that it can initiate the contact. The server sends the port number > and begins listening on that port. The client connects to that port, > the data is transferred, and the port is closed. > > When you set passive to FALSE, active mode is used. The most likely > reason it fails for you is that you are behind a router doing NAT > (Network Address Translation). The client tells the server to contact > it on some port, at the IP address assigned it by the router - which > is a nonroutable address which is basically made up by the router. The > server cannot make a contact on that address. In this environment you > *must* use passive mode FTP, so that the client can initiate the > contact. > Thanks for that. It does make perfect sense now. We are indeed behind a router and I will add a warning message. But, I was wondering, if I was to derive the classes, (CInternetSession and/or CFtpConnection), would there be a way to get messages so that the application does not 'hang' while waiting to timeout? I still want to give the option of passive/not passive but I need to get messages to the user to refresh the screen. And one last question, is there a way of 'testing' what setting might be best so I can offer a default to the user? Many thanks for your help. Simon
|
Pages: 1 Prev: 'GetDefaultPrinter' : undeclared identifier. Next: entering Unicode characters |