#include <socketeventshandler.h>
Public Types | |
enum | check_for_t { READ = 1, WRITE = 2, EXCEPT = 4, NOTHING = 8 } |
Public Member Functions | |
SocketEventsHandler () | |
int | add (Socket &sock, check_for_t checkfor, SocketEvents &se) |
int | del (Socket &sock) |
bool | enableSocket (const Socket &sock) |
bool | disableSocket (const Socket &sock) |
int | waitForEvents () |
virtual void * | entry_point () |
Classes | |
struct | socket_extra_t |
Definition at line 26 of file socketeventshandler.h.
READ | Checks for readable socket |
WRITE | Checks for writeable socket |
EXCEPT | Checks for exception on socket |
NOTHING | Dont checks the socket. It enable/disable the state. |
Definition at line 32 of file socketeventshandler.h.
n2nc::net::SocketEventsHandler::SocketEventsHandler | ( | ) |
The class should have one instance only.(singleton pattern)
Definition at line 8 of file socketeventshandler.cpp.
int n2nc::net::SocketEventsHandler::add | ( | Socket & | sock, | |
check_for_t | checkfor, | |||
SocketEvents & | se | |||
) |
Adds a Socket to wait for events. If se is NULL or omitted, then this Socket sock will not use SocketEvents paradigm.
Definition at line 22 of file socketeventshandler.cpp.
References n2nc::net::Socket::getFD(), n2nc::sync::Mutex::lock(), and n2nc::sync::Mutex::unlock().
Referenced by n2nc::Server::listen().
int n2nc::net::SocketEventsHandler::del | ( | Socket & | sock | ) |
Removes sock from handler
Definition at line 43 of file socketeventshandler.cpp.
References n2nc::net::Socket::getFD(), n2nc::sync::Mutex::lock(), and n2nc::sync::Mutex::unlock().
int n2nc::net::SocketEventsHandler::waitForEvents | ( | ) |
Main loop to catch up all events related to Socket.
Definition at line 65 of file socketeventshandler.cpp.
References n2nc::sync::Thread::run().
Referenced by n2nc::Server::listen().
void * n2nc::net::SocketEventsHandler::entry_point | ( | ) | [virtual] |
must implements thread code
Implements n2nc::sync::Thread.
Definition at line 59 of file socketeventshandler.cpp.