|
|
A TCP network socket
char * host | host |
[private]
unsigned short port | port |
[private]
int sockfd | sockfd |
[private]
void
init ( const char * host,
unsigned short port )
throw ( Exception ) | init |
[private]
Initialize the object.
Parameters:
host | name of the host this socket connects to. |
port | port to connect to. |
Throws: Exception
void
strip ( void )
throw ( Exception ) | strip |
[private]
De-initialize the object.
Throws: Exception
inline
TcpSocket ( void )
throw ( Exception ) | TcpSocket |
[protected]
Default constructor. Always throws an Exception.
Throws: Exception
inline
TcpSocket ( const char * host,
unsigned short port )
throw ( Exception ) | TcpSocket |
Constructor.
Parameters:
host | name of the host this socket connects to. |
port | port to connect to. |
Throws: Exception
TcpSocket ( const TcpSocket & ss )
throw ( Exception ) | TcpSocket |
Copy constructor.
Parameters:
ss | the TcpSocket to copy. |
Throws: Exception
inline
~TcpSocket ( void )
throw ( Exception ) | ~TcpSocket |
[virtual]
Destructor.
Throws: Exception
inline TcpSocket &
operator= ( const TcpSocket & ss )
throw ( Exception ) | operator= |
[virtual]
Assignment operator.
Parameters:
ss | the TcpSocket to assign this to. |
Returns: a reference to this TcpSocket.
Throws: Exception
Reimplemented from Source.
inline const char *
getHost ( void )
throw () | getHost |
[const]
Get the host this socket connects to.
Returns: the host this socket connects to.
inline unsigned int
getPort ( void )
throw () | getPort |
[const]
Get the port this socket connects to.
Returns: the port this socket connects to.
bool
open ( void )
throw ( Exception ) | open |
[virtual]
Open the TcpSocket.
Returns: true if opening was successfull, false otherwise.
Throws: Exception
Reimplemented from Source.
inline bool
isOpen ( void )
throw () | isOpen |
[const virtual]
Check if the TcpSocket is open.
Returns: true if the TcpSocket is open, false otherwise.
Reimplemented from Source.
bool
canRead ( unsigned int sec,
unsigned int usec )
throw ( Exception ) | canRead |
[virtual]
Check if the TcpScoket can be read from. Blocks until the specified time for data to be available.
Parameters:
sec | the maximum seconds to block. |
usec | micro seconds to block after the full seconds. |
Returns: true if the TcpSocket is ready to be read from, false otherwise.
Throws: Exception
Reimplemented from Source.
unsigned int
read ( void * buf,
unsigned int len )
throw ( Exception ) | read |
[virtual]
Read from the TcpSocket.
Parameters:
buf | the buffer to read into. |
len | the number of bytes to read into buf |
Returns: the number of bytes read (may be less than len).
Throws: Exception
Reimplemented from Source.
bool
canWrite ( unsigned int sec,
unsigned int usec )
throw ( Exception ) | canWrite |
[virtual]
Check if the TcpSocket is ready to accept data. Blocks until the specified time for data to be available.
Parameters:
sec | the maximum seconds to block. |
usec | micro seconds to block after the full seconds. |
Returns: true if the TcpSocket is ready to accept data, false otherwise.
Throws: Exception
Reimplemented from Sink.
unsigned int
write ( const void * buf,
unsigned int len )
throw ( Exception ) | write |
[virtual]
Write data to the TcpSocket.
Parameters:
buf | the data to write. |
len | number of bytes to write from buf. |
Returns: the number of bytes written (may be less than len).
Throws: Exception
Reimplemented from Sink.
inline void
flush ( void )
throw ( Exception ) | flush |
[virtual]
Flush all data that was written to the TcpSocket to the underlying connection.
Throws: Exception
Reimplemented from Sink.
void
close ( void )
throw ( Exception ) | close |
[virtual]
Close the TcpSocket.
Throws: Exception
Reimplemented from Source.