@@ -77,67 +77,72 @@ class Net_API FTPClientSession
7777 enum FileType
7878 {
7979 TYPE_TEXT, // TYPE A (ASCII)
80- TYPE_BINARY // TYPE I (Image)
81- };
82-
83- FTPClientSession ();
84- // / Creates an FTPClientSession.
85- // /
86- // / Passive mode will be used for data transfers.
87-
88- explicit FTPClientSession (const StreamSocket& socket);
89- // / Creates an FTPClientSession using the given
90- // / connected socket for the control connection.
91- // /
92- // / Passive mode will be used for data transfers.
93-
94- FTPClientSession (const std::string& host,
95- Poco::UInt16 port = FTP_PORT,
96- const std::string& username = " " ,
97- const std::string& password = " " );
98- // / Creates an FTPClientSession using a socket connected
99- // / to the given host and port. If username is supplied,
100- // / login is attempted.
101- // /
102- // / Passive mode will be used for data transfers.
103-
80+ TYPE_BINARY // TYPE I (Image)
81+ };
82+
83+ FTPClientSession ();
84+ // / Creates an FTPClientSession.
85+ // /
86+ // / Passive mode will be used for data transfers.
87+
88+ explicit FTPClientSession (const StreamSocket& socket);
89+ // / Creates an FTPClientSession using the given
90+ // / connected socket for the control connection.
91+ // /
92+ // / Passive mode will be used for data transfers.
93+
94+ FTPClientSession (const std::string& host,
95+ Poco::UInt16 port = FTP_PORT,
96+ const std::string& username = " " ,
97+ const std::string& password = " " );
98+ // / Creates an FTPClientSession using a socket connected
99+ // / to the given host and port. If username is supplied,
100+ // / login is attempted.
101+ // /
102+ // / Passive mode will be used for data transfers.
103+
104104 virtual ~FTPClientSession ();
105105 // / Destroys the FTPClientSession.
106106
107107 void setTimeout (const Poco::Timespan& timeout);
108108 // / Sets the timeout for socket operations.
109109
110- Poco::Timespan getTimeout () const ;
111- // / Returns the timeout for socket operations.
112-
113- void setPassive (bool flag);
114- // / Enables (default) or disables FTP passive mode for this session.
115-
116- bool getPassive () const ;
117- // / Returns true iff passive mode is enabled for this connection.
118-
119- void open (const std::string& host,
120- Poco::UInt16 port,
121- const std::string& username = " " ,
122- const std::string& password = " " );
123- // / Opens the FTP connection to the given host and port.
124- // / If username is supplied, login is attempted.
125-
126- void login (const std::string& username, const std::string& password);
127- // / Authenticates the user against the FTP server. Must be
128- // / called before any other commands (except QUIT) can be sent.
110+ Poco::Timespan getTimeout () const ;
111+ // / Returns the timeout for socket operations.
112+
113+ void setPassive (bool flag, bool useRFC1738 = true );
114+ // / Enables (default) or disables FTP passive mode for this session.
115+ // /
116+ // / If useRFC1738 is true (the default), the RFC 1738
117+ // / EPSV command is used (with a fallback to PASV if EPSV fails)
118+ // / for switching to passive mode. The same applies to
119+ // / EPRT and PORT for active connections.
120+
121+ bool getPassive () const ;
122+ // / Returns true iff passive mode is enabled for this connection.
123+
124+ void open (const std::string& host,
125+ Poco::UInt16 port,
126+ const std::string& username = " " ,
127+ const std::string& password = " " );
128+ // / Opens the FTP connection to the given host and port.
129+ // / If username is supplied, login is attempted.
130+
131+ void login (const std::string& username, const std::string& password);
132+ // / Authenticates the user against the FTP server. Must be
133+ // / called before any other commands (except QUIT) can be sent.
129134 // /
130135 // / Sends a USER command followed by a PASS command with the
131136 // / respective arguments to the server.
132137 // /
133- // / Throws a FTPException in case of a FTP-specific error, or a
134- // / NetException in case of a general network communication failure.
138+ // / Throws a FTPException in case of a FTP-specific error, or a
139+ // / NetException in case of a general network communication failure.
135140
136- void logout ();
141+ void logout ();
137142
138- void close ();
139- // / Sends a QUIT command and closes the connection to the server.
140- // /
143+ void close ();
144+ // / Sends a QUIT command and closes the connection to the server.
145+ // /
141146 // / Throws a FTPException in case of a FTP-specific error, or a
142147 // / NetException in case of a general network communication failure.
143148
@@ -310,18 +315,18 @@ class Net_API FTPClientSession
310315 // / and waits for a response.
311316
312317 int sendCommand (const std::string& command, const std::string& arg, std::string& response);
313- // / Sends the given command verbatim to the server
314- // / and waits for a response.
318+ // / Sends the given command verbatim to the server
319+ // / and waits for a response.
315320
316- bool isOpen () const ;
317- // / Returns true if the connection with FTP server is opened.
321+ bool isOpen () const ;
322+ // / Returns true if the connection with FTP server is opened.
318323
319- bool isLoggedIn () const ;
320- // / Returns true if the session is logged in.
324+ bool isLoggedIn () const ;
325+ // / Returns true if the session is logged in.
321326
322327protected:
323- enum StatusClass
324- {
328+ enum StatusClass
329+ {
325330 FTP_POSITIVE_PRELIMINARY = 1 ,
326331 FTP_POSITIVE_COMPLETION = 2 ,
327332 FTP_POSITIVE_INTERMEDIATE = 3 ,
@@ -350,22 +355,22 @@ class Net_API FTPClientSession
350355 void sendPASV (SocketAddress& addr);
351356 void parseAddress (const std::string& str, SocketAddress& addr);
352357 void parseExtAddress (const std::string& str, SocketAddress& addr);
353- void endTransfer ();
354-
358+ void endTransfer ();
359+
355360private:
356- FTPClientSession (const FTPClientSession&);
357- FTPClientSession& operator = (const FTPClientSession&);
358-
359- std::string _host;
360- Poco::UInt16 _port;
361- DialogSocket* _pControlSocket;
362- SocketStream* _pDataStream;
363- bool _passiveMode;
364- FileType _fileType;
365- bool _supports1738;
366- bool _serverReady;
367- bool _isLoggedIn;
368- Poco::Timespan _timeout;
361+ FTPClientSession (const FTPClientSession&);
362+ FTPClientSession& operator = (const FTPClientSession&);
363+
364+ std::string _host;
365+ Poco::UInt16 _port;
366+ DialogSocket* _pControlSocket;
367+ SocketStream* _pDataStream;
368+ bool _passiveMode;
369+ FileType _fileType;
370+ bool _supports1738;
371+ bool _serverReady;
372+ bool _isLoggedIn;
373+ Poco::Timespan _timeout;
369374};
370375
371376
@@ -404,13 +409,13 @@ inline bool FTPClientSession::isPermanentNegative(int status)
404409
405410inline bool FTPClientSession::isOpen () const
406411{
407- return _pControlSocket != 0 ;
412+ return _pControlSocket != 0 ;
408413}
409414
410415
411416inline bool FTPClientSession::isLoggedIn () const
412417{
413- return _isLoggedIn;
418+ return _isLoggedIn;
414419}
415420
416421
0 commit comments