\hypertarget{class_b_m_a_socket}{}\section{B\+M\+A\+Socket Class Reference}
\label{class_b_m_a_socket}\index{B\+M\+A\+Socket@{B\+M\+A\+Socket}}


{\ttfamily \#include $<$B\+M\+A\+Socket.\+h$>$}



Inheritance diagram for B\+M\+A\+Socket\+:
\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=350pt]{class_b_m_a_socket__inherit__graph}
\end{center}
\end{figure}


Collaboration diagram for B\+M\+A\+Socket\+:\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=300pt]{class_b_m_a_socket__coll__graph}
\end{center}
\end{figure}
\subsection*{Public Member Functions}
\begin{DoxyCompactItemize}
\item 
\mbox{\Hypertarget{class_b_m_a_socket_adb2a05588a86a3f8b595ecd8e12b1c51}\label{class_b_m_a_socket_adb2a05588a86a3f8b595ecd8e12b1c51}} 
{\bfseries B\+M\+A\+Socket} (\hyperlink{class_b_m_a_e_poll}{B\+M\+A\+E\+Poll} \&e\+Poll)
\item 
\mbox{\Hypertarget{class_b_m_a_socket_a67e45d5eeeb26964e3509d58abe7762a}\label{class_b_m_a_socket_a67e45d5eeeb26964e3509d58abe7762a}} 
void \hyperlink{class_b_m_a_socket_a67e45d5eeeb26964e3509d58abe7762a}{set\+Descriptor} (int descriptor)
\begin{DoxyCompactList}\small\item\em Set the descriptor for the socket. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{class_b_m_a_socket_aaf06616205d8bc97d305d77c94996cb0}\label{class_b_m_a_socket_aaf06616205d8bc97d305d77c94996cb0}} 
int \hyperlink{class_b_m_a_socket_aaf06616205d8bc97d305d77c94996cb0}{get\+Descriptor} ()
\begin{DoxyCompactList}\small\item\em Get the descriptor for the socket. \end{DoxyCompactList}\item 
void \hyperlink{class_b_m_a_socket_ac1e63c2e54aff72c18cadc5f3bc9001f}{event\+Received} (struct epoll\+\_\+event event)
\begin{DoxyCompactList}\small\item\em Parse epoll event and call specified callbacks. \end{DoxyCompactList}\item 
void \hyperlink{class_b_m_a_socket_a97a173ec0f7b7667f4beb4a56e74c1b4}{write} (std\+::string data)
\item 
\mbox{\Hypertarget{class_b_m_a_socket_a525cbedfa4b3f62e81f34734a69110ab}\label{class_b_m_a_socket_a525cbedfa4b3f62e81f34734a69110ab}} 
void {\bfseries write} (char $\ast$buffer, int length)
\item 
\mbox{\Hypertarget{class_b_m_a_socket_ace059125ad6036f1d628169afdc3c891}\label{class_b_m_a_socket_ace059125ad6036f1d628169afdc3c891}} 
void {\bfseries output} (std\+::stringstream \&out)
\item 
virtual void \hyperlink{class_b_m_a_socket_acde955606cbe6ded534a08dff158796d}{on\+Registered} ()
\begin{DoxyCompactList}\small\item\em Called when the socket has finished registering with the epoll processing. \end{DoxyCompactList}\item 
virtual void \hyperlink{class_b_m_a_socket_a2527dc75b00281b3dad87cffafdc7363}{on\+Unregistered} ()
\begin{DoxyCompactList}\small\item\em Called when the socket has finished unregistering for the epoll processing. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{class_b_m_a_socket_a67812528cb237e2495d738dd959aca56}\label{class_b_m_a_socket_a67812528cb237e2495d738dd959aca56}} 
void \hyperlink{class_b_m_a_socket_a67812528cb237e2495d738dd959aca56}{enable} (bool mode)
\begin{DoxyCompactList}\small\item\em Enable the socket to read or write based upon buffer. \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Public Attributes}
\begin{DoxyCompactItemize}
\item 
\mbox{\Hypertarget{class_b_m_a_socket_a2f9f17ca8819f2b1b11bf5b09ff2bb37}\label{class_b_m_a_socket_a2f9f17ca8819f2b1b11bf5b09ff2bb37}} 
\begin{tabbing}
xx\=xx\=xx\=xx\=xx\=xx\=xx\=xx\=xx\=\kill
class \{\\
\} {\bfseries bufferSize}\\

\end{tabbing}\end{DoxyCompactItemize}
\subsection*{Protected Member Functions}
\begin{DoxyCompactItemize}
\item 
\mbox{\Hypertarget{class_b_m_a_socket_a0ab8695ad43d7c0a7999673ea023fda4}\label{class_b_m_a_socket_a0ab8695ad43d7c0a7999673ea023fda4}} 
void {\bfseries set\+Buffer\+Size} (int length)
\item 
virtual void \hyperlink{class_b_m_a_socket_ac2206da05ab857ec64c5d4addb04a4bf}{on\+Connected} ()
\begin{DoxyCompactList}\small\item\em Called when socket is open and ready to communicate. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{class_b_m_a_socket_ae11c2ff3d466f393dac7f5629e9f864d}\label{class_b_m_a_socket_ae11c2ff3d466f393dac7f5629e9f864d}} 
virtual void {\bfseries on\+T\+L\+S\+Init} ()
\item 
virtual void \hyperlink{class_b_m_a_socket_ad77bf590a4d9807bd8f0a81667903f2e}{on\+Data\+Received} (std\+::string data)=0
\begin{DoxyCompactList}\small\item\em Called when data is received from the socket. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{class_b_m_a_socket_a46952d01762fe4b54e4cae9dbf07f172}\label{class_b_m_a_socket_a46952d01762fe4b54e4cae9dbf07f172}} 
void {\bfseries shutdown} ()
\item 
virtual void \hyperlink{class_b_m_a_socket_aa0b03fb4b5a531fd9590bbd4102756eb}{receive\+Data} (char $\ast$buffer, int buffer\+Length)
\end{DoxyCompactItemize}
\subsection*{Protected Attributes}
\begin{DoxyCompactItemize}
\item 
\mbox{\Hypertarget{class_b_m_a_socket_a6a8f431adc915983ad25bd25523d40dd}\label{class_b_m_a_socket_a6a8f431adc915983ad25bd25523d40dd}} 
\hyperlink{class_b_m_a_e_poll}{B\+M\+A\+E\+Poll} \& {\bfseries e\+Poll}
\item 
\mbox{\Hypertarget{class_b_m_a_socket_acfd4416961ce5ad1f25d0a0f35a574d2}\label{class_b_m_a_socket_acfd4416961ce5ad1f25d0a0f35a574d2}} 
bool {\bfseries shut\+Down} = false
\end{DoxyCompactItemize}


\subsection{Detailed Description}
\hyperlink{class_b_m_a_socket}{B\+M\+A\+Socket}

The core component to managing a socket.

Hooks into the \hyperlink{class_b_m_a_e_poll}{B\+M\+A\+E\+Poll} through the registration and unregistration process and provides a communication socket of the specified protocol type. This object provides for all receiving data threading through use of the \hyperlink{class_b_m_a_e_poll}{B\+M\+A\+E\+Poll} object and also provides buffering for output data requests to the socket.

A program using a socket object can request to open a socket (file or network or whatever) and communicate through the streambuffer interface of the socket object.

The socket side of the \hyperlink{class_b_m_a_socket}{B\+M\+A\+Socket} accepts E\+P\+O\+L\+L\+IN event and will maintain the data in a buffer for the stream readers to read. A on\+Data\+Received event is then sent with the data received in the buffer that can be read through the stream.

When writing to the stream the data is written into a buffer and a E\+P\+O\+L\+L\+O\+UT is scheduled. Upon receiving the E\+P\+O\+L\+L\+O\+UT event then the buffer is written to the socket output. 

\subsection{Member Function Documentation}
\mbox{\Hypertarget{class_b_m_a_socket_ac1e63c2e54aff72c18cadc5f3bc9001f}\label{class_b_m_a_socket_ac1e63c2e54aff72c18cadc5f3bc9001f}} 
\index{B\+M\+A\+Socket@{B\+M\+A\+Socket}!event\+Received@{event\+Received}}
\index{event\+Received@{event\+Received}!B\+M\+A\+Socket@{B\+M\+A\+Socket}}
\subsubsection{\texorpdfstring{event\+Received()}{eventReceived()}}
{\footnotesize\ttfamily void B\+M\+A\+Socket\+::event\+Received (\begin{DoxyParamCaption}\item[{struct epoll\+\_\+event}]{event }\end{DoxyParamCaption})}



Parse epoll event and call specified callbacks. 

The event received from epoll is sent through the event\+Received method which will parse the event and call the read and write callbacks on the socket.

This method is called by the \hyperlink{class_b_m_a_e_poll}{B\+M\+A\+E\+Poll} object and should not be called from any user extended classes unless an epoll event is being simulated. \mbox{\Hypertarget{class_b_m_a_socket_ac2206da05ab857ec64c5d4addb04a4bf}\label{class_b_m_a_socket_ac2206da05ab857ec64c5d4addb04a4bf}} 
\index{B\+M\+A\+Socket@{B\+M\+A\+Socket}!on\+Connected@{on\+Connected}}
\index{on\+Connected@{on\+Connected}!B\+M\+A\+Socket@{B\+M\+A\+Socket}}
\subsubsection{\texorpdfstring{on\+Connected()}{onConnected()}}
{\footnotesize\ttfamily void B\+M\+A\+Socket\+::on\+Connected (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [protected]}, {\ttfamily [virtual]}}



Called when socket is open and ready to communicate. 

The on\+Connected method is called when the socket is ready to communicate. Writing to the socket can begin on this call to initiate a contact with the remote device. 

Reimplemented in \hyperlink{class_b_m_a_session_a0d382f77e98c53e966119c2563cbfef5}{B\+M\+A\+Session}.

\mbox{\Hypertarget{class_b_m_a_socket_ad77bf590a4d9807bd8f0a81667903f2e}\label{class_b_m_a_socket_ad77bf590a4d9807bd8f0a81667903f2e}} 
\index{B\+M\+A\+Socket@{B\+M\+A\+Socket}!on\+Data\+Received@{on\+Data\+Received}}
\index{on\+Data\+Received@{on\+Data\+Received}!B\+M\+A\+Socket@{B\+M\+A\+Socket}}
\subsubsection{\texorpdfstring{on\+Data\+Received()}{onDataReceived()}}
{\footnotesize\ttfamily virtual void B\+M\+A\+Socket\+::on\+Data\+Received (\begin{DoxyParamCaption}\item[{std\+::string}]{data }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [protected]}, {\ttfamily [pure virtual]}}



Called when data is received from the socket. 

The on\+Data\+Received method is called when the socket has received an event from epoll and there is data ready to be read from the socket. The default handler will pull the data and put it into the streambuf for the socket. E\+P\+O\+L\+L\+IN


\begin{DoxyParams}{Parameters}
{\em data} & the data that has been received from the socket. \\
\hline
\end{DoxyParams}


Implemented in \hyperlink{class_b_m_a_t_c_p_server_socket_ae562db0627e31f558189a4140a9d0a36}{B\+M\+A\+T\+C\+P\+Server\+Socket}, \hyperlink{class_b_m_a_session_a7e627773deafd5f38d05d57653385048}{B\+M\+A\+Session}, and \hyperlink{class_b_m_a_u_d_p_server_socket_aaec1d1fa5f874c7669574c3610cee24e}{B\+M\+A\+U\+D\+P\+Server\+Socket}.

\mbox{\Hypertarget{class_b_m_a_socket_acde955606cbe6ded534a08dff158796d}\label{class_b_m_a_socket_acde955606cbe6ded534a08dff158796d}} 
\index{B\+M\+A\+Socket@{B\+M\+A\+Socket}!on\+Registered@{on\+Registered}}
\index{on\+Registered@{on\+Registered}!B\+M\+A\+Socket@{B\+M\+A\+Socket}}
\subsubsection{\texorpdfstring{on\+Registered()}{onRegistered()}}
{\footnotesize\ttfamily void B\+M\+A\+Socket\+::on\+Registered (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [virtual]}}



Called when the socket has finished registering with the epoll processing. 

The on\+Registered method is called whenever the socket is registered with e\+Poll and socket communcation events can be started. \mbox{\Hypertarget{class_b_m_a_socket_a2527dc75b00281b3dad87cffafdc7363}\label{class_b_m_a_socket_a2527dc75b00281b3dad87cffafdc7363}} 
\index{B\+M\+A\+Socket@{B\+M\+A\+Socket}!on\+Unregistered@{on\+Unregistered}}
\index{on\+Unregistered@{on\+Unregistered}!B\+M\+A\+Socket@{B\+M\+A\+Socket}}
\subsubsection{\texorpdfstring{on\+Unregistered()}{onUnregistered()}}
{\footnotesize\ttfamily void B\+M\+A\+Socket\+::on\+Unregistered (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [virtual]}}



Called when the socket has finished unregistering for the epoll processing. 

The on\+Unregistered method is called whenever the socket is unregistered with e\+Poll and socket communcation events will be stopped. The default method will close the socket and clean up the connection. If this is overridden by an extended object then the object should call this method to clean the socket up. \mbox{\Hypertarget{class_b_m_a_socket_aa0b03fb4b5a531fd9590bbd4102756eb}\label{class_b_m_a_socket_aa0b03fb4b5a531fd9590bbd4102756eb}} 
\index{B\+M\+A\+Socket@{B\+M\+A\+Socket}!receive\+Data@{receive\+Data}}
\index{receive\+Data@{receive\+Data}!B\+M\+A\+Socket@{B\+M\+A\+Socket}}
\subsubsection{\texorpdfstring{receive\+Data()}{receiveData()}}
{\footnotesize\ttfamily void B\+M\+A\+Socket\+::receive\+Data (\begin{DoxyParamCaption}\item[{char $\ast$}]{buffer,  }\item[{int}]{buffer\+Length }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [protected]}, {\ttfamily [virtual]}}

receive\+Data will read the data from the socket and place it in the socket buffer. T\+LS layer overrides this to be able to read from S\+SL. 

Reimplemented in \hyperlink{class_b_m_a_t_l_s_session_a052f9cb7df568a91ae2dc8d9e355afb5}{B\+M\+A\+T\+L\+S\+Session}.

\mbox{\Hypertarget{class_b_m_a_socket_a97a173ec0f7b7667f4beb4a56e74c1b4}\label{class_b_m_a_socket_a97a173ec0f7b7667f4beb4a56e74c1b4}} 
\index{B\+M\+A\+Socket@{B\+M\+A\+Socket}!write@{write}}
\index{write@{write}!B\+M\+A\+Socket@{B\+M\+A\+Socket}}
\subsubsection{\texorpdfstring{write()}{write()}}
{\footnotesize\ttfamily void B\+M\+A\+Socket\+::write (\begin{DoxyParamCaption}\item[{std\+::string}]{data }\end{DoxyParamCaption})}

Write data to the socket. 

The documentation for this class was generated from the following files\+:\begin{DoxyCompactItemize}
\item 
/home/barant/\+Development/\+B\+M\+A/server\+\_\+core/\+Server\+Core/B\+M\+A\+Socket.\+h\item 
/home/barant/\+Development/\+B\+M\+A/server\+\_\+core/\+Server\+Core/B\+M\+A\+Socket.\+cpp\end{DoxyCompactItemize}
