BMAEPoll Class Reference

`#include <BMAEPoll.h>`

Inheritance diagram for BMAEPoll:
[legend]
Collaboration diagram for BMAEPoll:
[legend]

## Public Member Functions

| BMAEPoll ()
| ~BMAEPoll ()
bool | start (int numberOfThreads, int maxSockets)
| Start the BMAEPoll processing. More...
bool | stop ()
| Stop and shut down the BMAEPoll processing. More...
bool | isStopping ()
| Returns a true if the stop command has been requested. More...
bool | registerSocket (BMASocket *socket)
| Register a BMASocket for monitoring by BMAEPoll. More...
bool | unregisterSocket (BMASocket *socket)
| Unregister a BMASocket from monitoring by BMAEPoll. More...
int | getDescriptor ()
| Return the descriptor for the ePoll socket. More...
void | eventReceived (struct epoll_event event)
| Dispatch event to appropriate socket. More...
void | processCommand (std::string command, BMASession *session) override
| Output the threads array to the console. More...
Public Member Functions inherited from BMACommand
| BMACommand (std::string commandName)
virtual void | output (BMASession *session)

## Public Attributes

int | maxSockets
| The maximum number of socket allowed. More...
Public Attributes inherited from BMACommand
std::string | commandName
Public Attributes inherited from BMAObject
std::string | name
std::string | tag

## Detailed Description

BMAEPoll

Manage socket events from the epoll system call.

Use this object to establish a socket server using the epoll network structure of Linux.

Use this object to establish the basis of working with multiple sockets of all sorts using the epoll capabilities of the Linux platform. Socket objects can register with BMAEPoll which will establish a communication mechanism with that socket.

The maximum number of sockets to communicate with is specified on the start method.

Threads are used to establish a read queue for epoll. The desired number of threads (or queues) is established by a parameter on the start method.

## Constructor & Destructor Documentation

## BMAEPoll()

BMAEPoll::BMAEPoll | ( |  | ) |

The constructor for the BMAEPoll object.

## ~BMAEPoll()

BMAEPoll::~BMAEPoll | ( |  | ) |

The destructor for the BMAEPoll object.

## Member Function Documentation

## eventReceived()

void BMAEPoll::eventReceived | ( | struct epoll_event | event | ) |

Dispatch event to appropriate socket.

Receive the epoll events and dispatch the event to the socket making the request.

## getDescriptor()

int BMAEPoll::getDescriptor | ( |  | ) |

Return the descriptor for the ePoll socket.

Use this method to obtain the current descriptor socket number for the epoll function call.

## isStopping()

bool BMAEPoll::isStopping | ( |  | ) |

Returns a true if the stop command has been requested.

This method returns a true if the stop() method has been called and the epoll system is shutting.

## processCommand()

void BMAEPoll::processCommand | ( | std::string | command,
|  | BMASession * | session
| ) |  |

overridevirtual

Output the threads array to the console.

The processCommand() method displays the thread array to the requesting console via the session passed as parameter.

Parameters

  session | the session to write the requested data to.

Implements BMACommand.

## registerSocket()

bool BMAEPoll::registerSocket | ( | BMASocket * | socket | ) |

Register a BMASocket for monitoring by BMAEPoll.

Use registerSocket to add a new socket to the ePoll event watch list. This enables a new BMASocket object to receive events when data is received as well as to write data output to the socket.

Parameters

  socket | a pointer to a BMASocket object.

Returns
  a booelean that indicates the socket was registered or not.

Parameters

  socket | The BMASocket to register.

## start()

bool BMAEPoll::start | ( | int | numberOfThreads,
|  | int | maxSockets
| ) |  |

Start the BMAEPoll processing.

Use the start() method to initiate the threads and begin epoll queue processing.

Parameters

  numberOfThreads | the number of threads to start for processing epoll entries.
  maxSockets | the maximum number of open sockets that epoll will manage.

## stop()

bool BMAEPoll::stop | ( |  | ) |

Stop and shut down the BMAEPoll processing.

Use the stop() method to initiate the shutdown process for the epoll socket management.

A complete shutdown of all managed sockets will be initiated by this method call.

## unregisterSocket()

bool BMAEPoll::unregisterSocket | ( | BMASocket * | socket | ) |

Unregister a BMASocket from monitoring by BMAEPoll.

Use this method to remove a socket from receiving events from the epoll system.

Parameters

  socket | The BMASocket to unregister.

## Member Data Documentation

## maxSockets

int BMAEPoll::maxSockets

The maximum number of socket allowed.

The maximum number of sockets that can be managed by the epoll system.

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

- /home/barant/Development/BMA/server_core/ServerCore/BMAEPoll.h
- /home/barant/Development/BMA/server_core/ServerCore/BMAEPoll.cpp