BMATCPServerSocket Class Referenceabstract

`#include <BMATCPServerSocket.h>`

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

## Public Member Functions

| BMATCPServerSocket (BMAEPoll &ePoll, std::string url, short int port, std::string commandName)
| ~BMATCPServerSocket ()
void | removeFromSessionList (BMASession *session)
Public Member Functions inherited from BMATCPSocket
| BMATCPSocket (BMAEPoll &ePoll)
void | connect (BMAIPAddress &address)
virtual void | output (std::stringstream &out)
Public Member Functions inherited from BMASocket
| BMASocket (BMAEPoll &ePoll)
void | setDescriptor (int descriptor)
| Set the descriptor for the socket.
int | getDescriptor ()
| Get the descriptor for the socket.
void | eventReceived (struct epoll_event event)
| Parse epoll event and call specified callbacks. More...
void | write (std::string data)
void | write (char *buffer, int length)
void | output (std::stringstream &out)
virtual void | onRegistered ()
| Called when the socket has finished registering with the epoll processing. More...
virtual void | onUnregistered ()
| Called when the socket has finished unregistering for the epoll processing. More...
void | enable (bool mode)
| Enable the socket to read or write based upon buffer.
Public Member Functions inherited from BMACommand
| BMACommand (std::string commandName)
virtual void | output (BMASession *session)

## Public Attributes

std::vector< BMASession * > | sessions
Public Attributes inherited from BMATCPSocket
BMAIPAddress | ipAddress
Public Attributes inherited from BMASocket
class {
} | bufferSize
Public Attributes inherited from BMAObject
std::string | name
std::string | tag
Public Attributes inherited from BMACommand
std::string | commandName

## Protected Member Functions

virtual void | init ()
virtual BMASession * | getSocketAccept ()=0
void | onDataReceived (std::string data) override
void | processCommand (std::string command, BMASession *session) override
Protected Member Functions inherited from BMASocket
void | setBufferSize (int length)
virtual void | onConnected ()
| Called when socket is open and ready to communicate. More...
virtual void | onTLSInit ()
void | shutdown ()
virtual void | receiveData (char *buffer, int bufferLength)

## Additional Inherited Members

Protected Attributes inherited from BMASocket
BMAEPoll & | ePoll
bool | shutDown = false

## Detailed Description

BMATCPServerSocket

Manage a socket connection as a TCP server type. Connections to the socket are processed through the accept functionality.

A list of connections is maintained in a vector object.

This object extends the BMACommand object as well so it can be added to a BMAConsole object and process commands to display status information.

## Constructor & Destructor Documentation

## BMATCPServerSocket()

BMATCPServerSocket::BMATCPServerSocket | ( | BMAEPoll & | ePoll,
|  | std::string | url,
|  | short int | port,
|  | std::string | commandName
| ) |  |

The constructor for the BMATCPSocket object.

Parameters

  ePoll | the BMAEPoll instance that manages the socket.
  url | the IP address for the socket to receive connection requests.
  port | the port number that the socket will listen on.
  commandName | the name of the command used to invoke the status display for this object.

Returns
  the instance of the BMATCPServerSocket.

## ~BMATCPServerSocket()

BMATCPServerSocket::~BMATCPServerSocket | ( |  | ) |

The destructor for this object.

## Member Function Documentation

## getSocketAccept()

virtual BMASession* BMATCPServerSocket::getSocketAccept | ( |  | ) |

protectedpure virtual

getSocketAccept is designed to allow a polymorphic extension of this object to return a type of object that extends the definition of the server socket. Returning the appropriate session object that extends from BMASession provides the mechanism where the server can select the protocol dialog for the desired service.

Implemented in BMATLSServerSocket, and BMAConsoleServer.

## onDataReceived()

void BMATCPServerSocket::onDataReceived | ( | std::string | data | ) |

overrideprotectedvirtual

Override the virtual dataReceived since for the server these are requests to accept the new connection socket. No data is to be read or written when this method is called. It is the response to the fact that a new connection is coming into the system

Parameters

  data | the pointer to the buffer containing the received data.
  length | the length of the associated data buffer.

Implements BMASocket.

## processCommand()

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

overrideprotectedvirtual

This method is called when the BMACommand associated with this object is requested because a user has typed in the associated command name on a command entry line.

Parameters

  the | session object to write the output to.

Implements BMACommand.

## Member Data Documentation

## sessions

std::vector<BMASession *> BMATCPServerSocket::sessions

The list of sessions that are currently open and being maintained by this object.

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

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