YGP::ConnectionMgr Class Reference

Class to handle the connections an application can have. More...

List of all members.

Public Types

enum  modeConnect { NONE, CLIENT, SERVER }

Public Member Functions

 ConnectionMgr ()
virtual ~ConnectionMgr ()
modeConnect getMode () const
void changeMode (modeConnect)
void disconnect (const Socket *partner)
void clearConnections ()
SocketgetSocket () const
Client mode
void connectTo (const std::string &server, unsigned int port) throw (YGP::CommError)
void connectTo (const char *server, unsigned int port) throw (YGP::CommError)
Server mode
void listenAt (unsigned int port) throw (YGP::CommError)
int getNewConnection () const
SocketaddConnection (int socket)
const std::vector< Socket * > & getClients () const


Detailed Description

Class to handle the connections an application can have.

There are two different modes:

Of course an object can switch between the states, in which case the previously created connections are closed and removed.


Member Enumeration Documentation

Mode of the connections.

Enumerator:
NONE  No action has been performed to set a mode.
CLIENT  Manager has connected to a server.
SERVER  Manager waited for connections from clients.


Constructor & Destructor Documentation

YGP::ConnectionMgr::ConnectionMgr (  ) 

Default constructor.

YGP::ConnectionMgr::~ConnectionMgr (  )  [virtual]

Destructor.


Member Function Documentation

Socket * YGP::ConnectionMgr::addConnection ( int  socket  ) 

Adds a connection the the server connections.

Returns:
Socket* Pointer to created socket (or NULL)
Precondition:

void YGP::ConnectionMgr::changeMode ( modeConnect  newMode  ) 

Changes the mode of the connection(s).

void YGP::ConnectionMgr::clearConnections (  ) 

Removes the available connections.

void YGP::ConnectionMgr::connectTo ( const char *  target,
unsigned int  port 
) throw (YGP::CommError)

Connect to server on the specified port.

Parameters:
target Server to connect to
port Port the server is listening at
Exceptions:
YGP::CommError In case of a connection error

void YGP::ConnectionMgr::connectTo ( const std::string &  server,
unsigned int  port 
) throw (YGP::CommError) [inline]

Connect to server on the specified port.

Exceptions:
YGP::CommError 

void YGP::ConnectionMgr::disconnect ( const Socket partner  ) 

Disconnects one of the partners.

Parameters:
partner Partner to disconnect

const std::vector<Socket*>& YGP::ConnectionMgr::getClients (  )  const [inline]

Returns the clients already connected to the server.

modeConnect YGP::ConnectionMgr::getMode (  )  const [inline]

Returns the actual mode of the connection.

int YGP::ConnectionMgr::getNewConnection (  )  const

Waits for a connection on the previously bound port.

Precondition:
listenAt() must have been called before

Socket* YGP::ConnectionMgr::getSocket (  )  const [inline]

Returns the Socket over which to communicate (might be NULL).

void YGP::ConnectionMgr::listenAt ( unsigned int  port  )  throw (YGP::CommError)

Wait at port port for connections.

Parameters:
port Port the server is listening at
Exceptions:
YGP::CommError In case of a connection error


The documentation for this class was generated from the following files:

YGP Version 0.9.31 - Generated on Wed Nov 18 11:25:27 2009 by doxygen 1.5.8