Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members

TcpSocket Class Reference

#include <TcpSocket.h>

Inheritance diagram for TcpSocket:

Inheritance graph
[legend]
Collaboration diagram for TcpSocket:

Collaboration graph
[legend]
List of all members.

Detailed Description

A TCP network socket.

Author:
Author
darkeye
Version:
Revision
1.3

Definition at line 57 of file TcpSocket.h.

Public Member Functions

 TcpSocket (const char *host, unsigned short port) throw ( Exception )
 Constructor.
 TcpSocket (const TcpSocket &ss) throw ( Exception )
 Copy constructor.
virtual ~TcpSocket (void) throw ( Exception )
 Destructor.
virtual TcpSocketoperator= (const TcpSocket &ss) throw ( Exception )
 Assignment operator.
const char * getHost (void) const throw ()
 Get the host this socket connects to.
unsigned int getPort (void) const throw ()
 Get the port this socket connects to.
virtual bool open (void) throw ( Exception )
 Open the TcpSocket.
virtual bool isOpen (void) const throw ()
 Check if the TcpSocket is open.
virtual bool canRead (unsigned int sec, unsigned int usec) throw ( Exception )
 Check if the TcpScoket can be read from.
virtual unsigned int read (void *buf, unsigned int len) throw ( Exception )
 Read from the TcpSocket.
virtual bool canWrite (unsigned int sec, unsigned int usec) throw ( Exception )
 Check if the TcpSocket is ready to accept data.
virtual unsigned int write (const void *buf, unsigned int len) throw ( Exception )
 Write data to the TcpSocket.
virtual void flush (void) throw ( Exception )
 Flush all data that was written to the TcpSocket to the underlying connection.
virtual void close (void) throw ( Exception )
 Close the TcpSocket.

Protected Member Functions

 TcpSocket (void) throw ( Exception )
 Default constructor.


Constructor & Destructor Documentation

TcpSocket::TcpSocket void   )  throw ( Exception ) [inline, protected]
 

Default constructor.

Always throws an Exception.

Exceptions:
Exception 

Definition at line 104 of file TcpSocket.h.

TcpSocket::TcpSocket const char *  host,
unsigned short  port
throw ( Exception ) [inline]
 

Constructor.

Parameters:
host name of the host this socket connects to.
port port to connect to.
Exceptions:
Exception 

Definition at line 120 of file TcpSocket.h.

TcpSocket::TcpSocket const TcpSocket ss  )  throw ( Exception )
 

Copy constructor.

Parameters:
ss the TcpSocket to copy.
Exceptions:
Exception 

Definition at line 136 of file TcpSocket.cpp.

virtual TcpSocket::~TcpSocket void   )  throw ( Exception ) [inline, virtual]
 

Destructor.

Exceptions:
Exception 

Definition at line 140 of file TcpSocket.h.


Member Function Documentation

bool TcpSocket::canRead unsigned int  sec,
unsigned int  usec
throw ( Exception ) [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.
Exceptions:
Exception 

Implements Source.

Definition at line 241 of file TcpSocket.cpp.

bool TcpSocket::canWrite unsigned int  sec,
unsigned int  usec
throw ( Exception ) [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.
Exceptions:
Exception 

Implements Sink.

Definition at line 294 of file TcpSocket.cpp.

void TcpSocket::close void   )  throw ( Exception ) [virtual]
 

Close the TcpSocket.

Exceptions:
Exception 

Implements Sink.

Definition at line 355 of file TcpSocket.cpp.

References flush(), and isOpen().

Referenced by open().

virtual void TcpSocket::flush void   )  throw ( Exception ) [inline, virtual]
 

Flush all data that was written to the TcpSocket to the underlying connection.

Exceptions:
Exception 

Implements Sink.

Definition at line 257 of file TcpSocket.h.

Referenced by close().

const char* TcpSocket::getHost void   )  const throw () [inline]
 

Get the host this socket connects to.

Returns:
the host this socket connects to.

Definition at line 161 of file TcpSocket.h.

unsigned int TcpSocket::getPort void   )  const throw () [inline]
 

Get the port this socket connects to.

Returns:
the port this socket connects to.

Definition at line 172 of file TcpSocket.h.

virtual bool TcpSocket::isOpen void   )  const throw () [inline, virtual]
 

Check if the TcpSocket is open.

Returns:
true if the TcpSocket is open, false otherwise.

Implements Sink.

Definition at line 192 of file TcpSocket.h.

Referenced by close(), and open().

bool TcpSocket::open void   )  throw ( Exception ) [virtual]
 

Open the TcpSocket.

Returns:
true if opening was successfull, false otherwise.
Exceptions:
Exception 

Implements Sink.

Definition at line 187 of file TcpSocket.cpp.

References close(), and isOpen().

TcpSocket & TcpSocket::operator= const TcpSocket ss  )  throw ( Exception ) [inline, virtual]
 

Assignment operator.

Parameters:
ss the TcpSocket to assign this to.
Returns:
a reference to this TcpSocket.
Exceptions:
Exception 

Definition at line 156 of file TcpSocket.cpp.

References Source::operator=(), and Sink::operator=().

unsigned int TcpSocket::read void *  buf,
unsigned int  len
throw ( Exception ) [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).
Exceptions:
Exception 

Implements Source.

Definition at line 271 of file TcpSocket.cpp.

unsigned int TcpSocket::write const void *  buf,
unsigned int  len
throw ( Exception ) [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).
Exceptions:
Exception 

Implements Sink.

Definition at line 324 of file TcpSocket.cpp.


The documentation for this class was generated from the following files:
Generated on Sat Oct 22 13:17:07 2005 for DarkIce by  doxygen 1.4.4