Collage  1.0.1
Object-Oriented C++ Network Library
Public Types | Public Member Functions | List of all members
co::ConnectionSet Class Reference

Handles events on a set of connections. More...

#include <connectionSet.h>

Public Types

enum  Event {
  EVENT_NONE = 0, EVENT_CONNECT, EVENT_DISCONNECT, EVENT_DATA,
  EVENT_TIMEOUT, EVENT_INTERRUPT, EVENT_ERROR, EVENT_SELECT_ERROR,
  EVENT_INVALID_HANDLE, EVENT_ALL
}
 < Event types for select() More...
 

Public Member Functions

CO_API ConnectionSet ()
 Create a new connection set. More...
 
CO_API ~ConnectionSet ()
 Destruct this connection set. More...
 
Managing connections
CO_API void addConnection (ConnectionPtr connection)
 Add the connection to this set. More...
 
CO_API bool removeConnection (ConnectionPtr connection)
 Remove the connection from this set. More...
 
CO_API size_t getSize () const
 Remove all connections from this set. More...
 
CO_API bool isEmpty () const
 
CO_API const ConnectionsgetConnections () const
 
Performing a selection
CO_API Event select (const uint32_t timeout=LB_TIMEOUT_INDEFINITE)
 Select a Connection which is ready for I/O. More...
 
CO_API void interrupt ()
 Interrupt the current or next select call. More...
 
CO_API int getError () const
 
CO_API ConnectionPtr getConnection ()
 
void setDirty ()
 

Detailed Description

Handles events on a set of connections.

Definition at line 32 of file connectionSet.h.

Member Enumeration Documentation

< Event types for select()

Enumerator
EVENT_NONE 

No event has occurred.

EVENT_CONNECT 

A new connection.

EVENT_DISCONNECT 

A disconnect.

EVENT_DATA 

Data can be read.

EVENT_TIMEOUT 

The selection request timed out.

EVENT_INTERRUPT 

ConnectionSet::interrupt was called.

EVENT_ERROR 

A connection signaled an error.

EVENT_SELECT_ERROR 

An error occurred during select()

EVENT_INVALID_HANDLE 

A connection is not select'able.

Definition at line 35 of file connectionSet.h.

Constructor & Destructor Documentation

CO_API co::ConnectionSet::ConnectionSet ( )

Create a new connection set.

Version
1.0
CO_API co::ConnectionSet::~ConnectionSet ( )

Destruct this connection set.

Version
1.0

Member Function Documentation

CO_API void co::ConnectionSet::addConnection ( ConnectionPtr  connection)

Add the connection to this set.

Thread-safe.

Version
1.0
CO_API ConnectionPtr co::ConnectionSet::getConnection ( )
Returns
the connection of the last select event, may be 0.
Version
1.0
CO_API int co::ConnectionSet::getError ( ) const
Returns
the error code when the last select() returned EVENT_ERROR.
Version
1.0
CO_API size_t co::ConnectionSet::getSize ( ) const

Remove all connections from this set.

Thread-safe.

Version
1.0
CO_API void co::ConnectionSet::interrupt ( )

Interrupt the current or next select call.

Version
1.0
CO_API bool co::ConnectionSet::isEmpty ( ) const
Returns
true if this set has no connections. Thread-safe.
Version
1.0
CO_API bool co::ConnectionSet::removeConnection ( ConnectionPtr  connection)

Remove the connection from this set.

Thread-safe.

Version
1.0
CO_API Event co::ConnectionSet::select ( const uint32_t  timeout = LB_TIMEOUT_INDEFINITE)

Select a Connection which is ready for I/O.

Depending on the event, the error number and connection are set.

Parameters
timeoutthe timeout to wait for an event in milliseconds, or LB_TIMEOUT_INDEFINITE if the call should block forever.
Returns
The type of the event occured during selection.
See Also
getConnection(), getError()
Version
1.0

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