Class for TCPTransfers.
More...
#include <TCPTransfer.h>
List of all
members.
|
Public Types
|
| typedef int |
Socket |
| |
typdef for Socket
|
| enum |
Status {
OK = 0, GETHOSTBYNAME__ERROR,
SOCKET__ERROR, CONNECT__ERROR,
RECV__ERROR, OUTOFMEMORY__ERROR,
BODY__ERROR, UNKNOWN__ERROR,
ADDRESS__ERROR, UNINITIALIZED__ERROR,
TRANSFER__ERROR, SEND__ERROR,
PORT__ERROR, UNKNOWN_PROTOCOL__ERROR,
LOGON__ERROR, PROXY__ERROR,
FILENOTFOUND__ERROR = 404
} |
| |
Enumeration of some status codes.
More...
|
| enum |
Protocol {
UNKNOWN_PROTOCOL = 0, HTTP_PROTOCOL = 1,
FTP_PROTOCOL = 2 } |
| |
Enumeration of the supported
protocols. More...
|
Public Member Functions
|
| |
TCPTransfer ()
throw () |
| |
Default constructor.
|
| |
TCPTransfer
(std::ostream &file, const String &address) throw
(TransferFailed) |
| |
Detailled constructor.
|
| virtual
|
~TCPTransfer ()
throw () |
| |
Destructor.
|
| void |
clear () throw
() |
| |
Clear method.
|
| bool |
set
(::std::ostream &file, const String &address) throw
() |
| |
Set method.
|
| void |
set
(::std::ostream &file, Protocol protocol,
const String &host_address,
const String &file_address,
const String &login, const
String
&password, Position port=80) throw
() |
| |
Detailled set method.
|
| const String & |
getHostAddress
() const throw () |
| |
Return the host address.
|
| const
String
& |
getFileAddress
() const throw () |
| |
Return the file address.
|
| Position |
getPort ()
const throw () |
| |
Return the port number.
|
| Status |
getStatusCode
() const throw () |
| |
Return the status code.
|
| String |
getErrorCode () const throw () |
|
Position
|
getReceivedBytes
() const throw () |
| |
Return the amount of received
bytes.
|
| Protocol |
getProtocol ()
const throw () |
| |
Return the protocol.
|
| const String & |
getLogin ()
const throw () |
| |
Return the login.
|
| const
String
& |
getPassword ()
const throw () |
| |
Return the password.
|
| const
::std::ostream * |
getStream ()
const throw () |
| |
Get a pointer to the
stream.
|
| const char * |
getBuffer ()
const throw () |
| |
Return a pointer to the buffer.
|
| Status |
transfer ()
throw () |
| |
Transfer method.
|
| void |
setProxy
(const String proxy_address,
Position
port) |
| bool |
usingProxy
() const |
| void |
abort () |
| |
abort a running transfer
|
| void |
dump
(std::ostream &s=std::cout, Size depth=0) const throw
() |
| |
Dump the content of the buffer to an
ostream.
|
Protected Member Functions
|
| Status |
sendData_
(const String &query, Socket
socket) throw () |
| Status |
logon_
(const String &query) throw
() |
| Status |
getFTP_ ()
throw () |
| Status |
getHTTP_ ()
throw () |
| bool |
getFTPMessage_ (Index status) throw () |
| Status
|
getFTPStatus_ () throw () |
| Status
|
getHTTPStatus_ () throw () |
| Status |
setBlock_
(Socket socket, bool
block=true) throw () |
| bool |
waitForOutput_ (const String &key, Size seconds) throw
() |
| int
|
getReceivedBytes_ (Socket
&socket) |
Protected Attributes
|
| String |
host_address_ |
| String |
file_address_ |
| Position |
port_ |
| String |
login_ |
| String |
password_ |
| Status |
status_ |
| int |
received_bytes_ |
| Protocol |
protocol_ |
| char |
buffer_
[BUFFER_SIZE+1] |
| Socket |
socket_ |
| std::ostream *
|
fstream_ |
| String |
proxy_address_ |
| Position |
proxy_port_ |
| bool |
abort_ |
Private Member Functions
|
| void |
operator=
(TCPTransfer) throw
() |
Detailed Description
Class for TCPTransfers.
You can use http and ftp protocol to transfer files from the
internet and store them in an ostream. Support for login,
password and port is build in for FTP and HTTP. FTP transports
are done by passive FTP, so no problems with local firewalls
are encountered.
Member Enumeration Documentation
| |
Enumeration of the supported protocols.
|
| |
Enumeration of some status codes.
In addition to these TCPTransfer can also
return the status codes of HTTP and FTP.
|
Constructor & Destructor Documentation
|
BALL::TCPTransfer::TCPTransfer |
( |
|
) |
throw () |
|
| |
Default constructor.
The instance is set to UNINITIALIZED__ERROR.
|
|
BALL::TCPTransfer::TCPTransfer |
( |
std::ostream & |
file, |
|
|
const String &
|
address |
|
) |
throw (TransferFailed) |
|
| |
Detailled constructor.
The file from the given address is downloaded and
stored in the ostream instance. You can specify protocol,
port and a login/pass by using the syntax:
- http[ftp]://login:pass@server.com:port/fileaddress
|
Member Function Documentation
| void
BALL::TCPTransfer::clear |
( |
|
) |
throw () |
|
| |
Clear method.
All attributes are set to default values and the
status is set to UNINITIALIZED__ERROR.
|
| void
BALL::TCPTransfer::dump |
( |
std::ostream & |
s =
std::cout, |
|
|
Size |
depth =
0 |
|
) |
const throw () |
|
| |
Dump the content of the buffer to an ostream.
- Parameters:
-
|
s |
the stream to which we will dump |
|
depth |
the indentation depth of the output |
|
| const
char* BALL::TCPTransfer::getBuffer |
( |
|
) |
const throw ()
[inline] |
|
| |
Return a pointer to the buffer.
Remember that the buffer may contain NULL-chars. The
length of the buffer is less than BUFFER_LENGTH. This
method should only be used for debuging.
|
| const
String&
BALL::TCPTransfer::getHostAddress |
( |
|
) |
const throw ()
[inline] |
|
| Protocol
BALL::TCPTransfer::getProtocol |
( |
|
) |
const throw ()
[inline] |
|
| Status
BALL::TCPTransfer::getStatusCode |
( |
|
) |
const throw ()
[inline] |
|
| |
Return the status code.
- See also:
- Status
|
| void
BALL::TCPTransfer::set |
( |
::std::ostream & |
file, |
|
|
Protocol
|
protocol, |
|
|
const String &
|
host_address, |
|
|
const String &
|
file_address, |
|
|
const String &
|
login, |
|
|
const String &
|
password, |
|
|
Position |
port =
80 |
|
) |
throw () |
|
| |
Detailled set method.
- See also:
- set(ostream& file, const String&
address)
|
| bool
BALL::TCPTransfer::set |
( |
::std::ostream & |
file, |
|
|
const String &
|
address |
|
) |
throw () |
|
| |
Set method.
You can set a new file and address, but the transfer
is not yet done. To do that, use transfer()
afterwards.
|
| Status
BALL::TCPTransfer::transfer |
( |
|
) |
throw () |
|
| |
Transfer method.
If the address is specified, the file can be
transfered with this method.
- Returns:
- Status the status of the transfer/instance
- See also:
- Status
|
The documentation for this class was generated from the
following file: