n2nc::net::SocketEventsHandler Class Reference

Provides asynchronus socket managment. this class provides a method to handle all events generated by Socket. Basically it starts a new thread which poll on any Socket by using select(), it generates a callback event defined in SocketEvents interface. This way avoid the plenty use of select() and move programmer to a event-based socket management. More...

#include <socketeventshandler.h>

Inheritance diagram for n2nc::net::SocketEventsHandler:

Inheritance graph
[legend]
Collaboration diagram for n2nc::net::SocketEventsHandler:

Collaboration graph
[legend]

List of all members.

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


Detailed Description

Provides asynchronus socket managment. this class provides a method to handle all events generated by Socket. Basically it starts a new thread which poll on any Socket by using select(), it generates a callback event defined in SocketEvents interface. This way avoid the plenty use of select() and move programmer to a event-based socket management.

Author:
fabsoft <fabsoft@gmail.com>

Definition at line 26 of file socketeventshandler.h.


Member Enumeration Documentation

Enumerator:
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.


Constructor & Destructor Documentation

n2nc::net::SocketEventsHandler::SocketEventsHandler (  ) 

The class should have one instance only.(singleton pattern)

Definition at line 8 of file socketeventshandler.cpp.


Member Function Documentation

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().

Here is the call graph for this function:

Here is the caller graph for this function:

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().

Here is the call graph for this function:

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().

Here is the call graph for this function:

Here is the caller graph for this function:

void * n2nc::net::SocketEventsHandler::entry_point (  )  [virtual]

must implements thread code

Implements n2nc::sync::Thread.

Definition at line 59 of file socketeventshandler.cpp.


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

Generated on Mon Oct 6 19:32:52 2008 for n2nc by  doxygen 1.5.5