class TcpSocket

A TCP network socket More...

Definition#include <TcpSocket.h>
InheritsSink [public ], Source [public ]
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

Public Methods

Protected Methods

Private Methods

Private Members


Detailed Description

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:
hostname of the host this socket connects to.
portport 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:
hostname of the host this socket connects to.
portport to connect to.

Throws: Exception

 TcpSocket ( const TcpSocket & ss )
throw ( Exception )

TcpSocket

Copy constructor.

Parameters:
ssthe 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:
ssthe 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:
secthe maximum seconds to block.
usecmicro 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:
bufthe buffer to read into.
lenthe 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:
secthe maximum seconds to block.
usecmicro 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:
bufthe data to write.
lennumber 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.