The Micro C++ Library
|
A SocketSet resembles fd_set
the BSD compliant set of sockets used with select
and synchronous I/O multiplexing.
More...
#include <micxx.hxx>
Inherits micxx::Mutex.
Public Types | |
typedef std::map< socket_t, Socket * > | SocketMap |
typedef SocketMap::iterator | iterator |
typedef SocketMap::const_iterator | const_iterator |
Public Member Functions | |
SocketSet () | |
Create a new and empty SocketSet. | |
virtual | ~SocketSet () |
Deletes all pointers of micxx::Sockets that are still stored within this SocketSet. | |
virtual void | add (Socket *socket) |
Add the specified socket to the stored set of sockets. | |
virtual iterator | begin () |
An iterator that points to the first Socket of this SocketSet. | |
virtual const_iterator | begin () const |
A const_iterator that points to the first Socket of this SocketSet. | |
virtual iterator | end () |
An iterator that points behind the last Socket of this SocketSet. | |
virtual const_iterator | end () const |
An const_iterator that points behind the last Socket of this SocketSet. | |
virtual void | clear () |
Remove all Sockets from the stored set of sockets. | |
virtual void | close () |
Close all Sockets from this SocketSet. | |
virtual bool | remove (Socket *socket) |
Remove the specified socket from this SocketSet. | |
virtual Socket * | selectRead () |
Wait until data is available to be read from one of the stored Sockets without blocking the calling thread. |
A SocketSet resembles fd_set
the BSD compliant set of sockets used with select
and synchronous I/O multiplexing.
For this purpose references to Sockets must be added to the SocketSet and then a call to selectRead() would block the calling thread, until one of the stored Sockets from this SocketSet changes its state, so that at least some data could be read from the returned Socket without blocking the calling thread.
typedef SocketMap::const_iterator micxx::SocketSet::const_iterator |
typedef SocketMap::iterator micxx::SocketSet::iterator |
typedef std::map<socket_t,Socket*> micxx::SocketSet::SocketMap |
micxx::SocketSet::SocketSet | ( | ) |
Create a new and empty SocketSet.
virtual micxx::SocketSet::~SocketSet | ( | ) | [virtual] |
Deletes all pointers of micxx::Sockets that are still stored within this SocketSet.
virtual void micxx::SocketSet::add | ( | Socket * | socket | ) | [virtual] |
Add the specified socket to the stored set of sockets.
As long as the socket is not removed from this SocketSet (either by remove(Socket*) or by clear()), the socket is deleted automatically when this SocketSet is deallocated.
(socket_t)socket != INVALID_SOCKET.
virtual iterator micxx::SocketSet::begin | ( | ) | [inline, virtual] |
virtual const_iterator micxx::SocketSet::begin | ( | ) | const [inline, virtual] |
virtual void micxx::SocketSet::clear | ( | ) | [inline, virtual] |
virtual const_iterator micxx::SocketSet::end | ( | ) | const [inline, virtual] |
virtual iterator micxx::SocketSet::end | ( | ) | [inline, virtual] |
virtual bool micxx::SocketSet::remove | ( | Socket * | socket | ) | [virtual] |
Remove the specified socket from this SocketSet.
The removed Socket is not deleted by remove(Socket*). The application regains ownership of the removed Socket.
true
, if the socket has been removed,false
otherwise. virtual Socket* micxx::SocketSet::selectRead | ( | ) | [virtual] |