230 lines
15 KiB
TeX
230 lines
15 KiB
TeX
\hypertarget{classcore_1_1Socket}{}\doxysection{core\+::Socket Class Reference}
|
|
\label{classcore_1_1Socket}\index{core::Socket@{core::Socket}}
|
|
|
|
|
|
{\ttfamily \#include $<$Socket.\+h$>$}
|
|
|
|
|
|
|
|
Inheritance diagram for core\+::Socket\+:\nopagebreak
|
|
\begin{figure}[H]
|
|
\begin{center}
|
|
\leavevmode
|
|
\includegraphics[width=350pt]{classcore_1_1Socket__inherit__graph}
|
|
\end{center}
|
|
\end{figure}
|
|
|
|
|
|
Collaboration diagram for core\+::Socket\+:\nopagebreak
|
|
\begin{figure}[H]
|
|
\begin{center}
|
|
\leavevmode
|
|
\includegraphics[width=174pt]{classcore_1_1Socket__coll__graph}
|
|
\end{center}
|
|
\end{figure}
|
|
\doxysubsection*{Public Member Functions}
|
|
\begin{DoxyCompactItemize}
|
|
\item
|
|
\mbox{\hyperlink{classcore_1_1Socket_a4c3f87fd1de3c9eab4bf5efbb30ce87d}{Socket}} (\mbox{\hyperlink{classcore_1_1EPoll}{EPoll}} \&e\+Poll, std\+::string text=\char`\"{}\char`\"{})
|
|
\item
|
|
virtual \mbox{\hyperlink{classcore_1_1Socket_aa5003845f8ae464ad2fa206176381be0}{$\sim$\+Socket}} ()
|
|
\item
|
|
void \mbox{\hyperlink{classcore_1_1Socket_af2d1b6de7a64a9d446b0305b6ec47b31}{shutdown}} (std\+::string text=\char`\"{}unknown\char`\"{})
|
|
\item
|
|
void \mbox{\hyperlink{classcore_1_1Socket_ac44f6ae3196a8a3e09a6a85fcf495762}{set\+Descriptor}} (int descriptor)
|
|
\begin{DoxyCompactList}\small\item\em Set the descriptor for the socket. \end{DoxyCompactList}\item
|
|
\mbox{\Hypertarget{classcore_1_1Socket_a06ba54744530439d4131e6aba4623d08}\label{classcore_1_1Socket_a06ba54744530439d4131e6aba4623d08}}
|
|
int \mbox{\hyperlink{classcore_1_1Socket_a06ba54744530439d4131e6aba4623d08}{get\+Descriptor}} ()
|
|
\begin{DoxyCompactList}\small\item\em Get the descriptor for the socket. \end{DoxyCompactList}\item
|
|
bool \mbox{\hyperlink{classcore_1_1Socket_a1a045e15fb5851d666a21be05ac4c5d7}{event\+Received}} (struct epoll\+\_\+event event, long long event\+Id)
|
|
\begin{DoxyCompactList}\small\item\em Parse epoll event and call specified callbacks. \end{DoxyCompactList}\item
|
|
int \mbox{\hyperlink{classcore_1_1Socket_a4ed587f31d080115c00828f90b1e28bb}{write}} (std\+::string data, \mbox{\hyperlink{classcore_1_1Socket}{Socket}} $\ast$sender)
|
|
\item
|
|
\mbox{\Hypertarget{classcore_1_1Socket_a4855594af113428eacdaa7448d661121}\label{classcore_1_1Socket_a4855594af113428eacdaa7448d661121}}
|
|
void {\bfseries write} (char $\ast$buffer, int length)
|
|
\item
|
|
\mbox{\Hypertarget{classcore_1_1Socket_ad67b0f95127bd987b98323120f40f6ed}\label{classcore_1_1Socket_ad67b0f95127bd987b98323120f40f6ed}}
|
|
void {\bfseries output} (std\+::stringstream \&out)
|
|
\item
|
|
virtual void \mbox{\hyperlink{classcore_1_1Socket_a81e5ee3e17834166d97c6e8b7dfe0da0}{on\+Register}} ()
|
|
\begin{DoxyCompactList}\small\item\em Called before the socket has registered with the epoll processing. \end{DoxyCompactList}\item
|
|
\mbox{\Hypertarget{classcore_1_1Socket_a23b9824653bbe4652a716acb828665b1}\label{classcore_1_1Socket_a23b9824653bbe4652a716acb828665b1}}
|
|
virtual void \mbox{\hyperlink{classcore_1_1Socket_a23b9824653bbe4652a716acb828665b1}{on\+Registered}} ()
|
|
\begin{DoxyCompactList}\small\item\em Called after the socket has been registered with epoll processing. \end{DoxyCompactList}\item
|
|
\mbox{\Hypertarget{classcore_1_1Socket_aa1d380db54a5b2efbc859e3744bd898b}\label{classcore_1_1Socket_aa1d380db54a5b2efbc859e3744bd898b}}
|
|
virtual void {\bfseries on\+Unregister} ()
|
|
\item
|
|
virtual void \mbox{\hyperlink{classcore_1_1Socket_ae9be59697c2b2e5efb19aaae3ba943d2}{on\+Unregistered}} ()
|
|
\begin{DoxyCompactList}\small\item\em Called when the socket has finished unregistering for the epoll processing. \end{DoxyCompactList}\item
|
|
\mbox{\Hypertarget{classcore_1_1Socket_a43247bfe43c2be5ab3863d9057d46b7c}\label{classcore_1_1Socket_a43247bfe43c2be5ab3863d9057d46b7c}}
|
|
bool {\bfseries needs\+To\+Write} ()
|
|
\end{DoxyCompactItemize}
|
|
\doxysubsection*{Public Attributes}
|
|
\begin{DoxyCompactItemize}
|
|
\item
|
|
\mbox{\Hypertarget{classcore_1_1Socket_a9f9a89f5caab42f77b3759ceb54a0a78}\label{classcore_1_1Socket_a9f9a89f5caab42f77b3759ceb54a0a78}}
|
|
bool {\bfseries reset} = false
|
|
\item
|
|
\mbox{\Hypertarget{classcore_1_1Socket_a6303734821a2979f7b19add6ce1367b9}\label{classcore_1_1Socket_a6303734821a2979f7b19add6ce1367b9}}
|
|
volatile bool {\bfseries shut\+Down} = false
|
|
\end{DoxyCompactItemize}
|
|
\doxysubsection*{Protected Member Functions}
|
|
\begin{DoxyCompactItemize}
|
|
\item
|
|
\mbox{\Hypertarget{classcore_1_1Socket_a71c77a162698b9c074a7497beab7b5d8}\label{classcore_1_1Socket_a71c77a162698b9c074a7497beab7b5d8}}
|
|
void {\bfseries set\+Buffer\+Size} (int length)
|
|
\item
|
|
\mbox{\Hypertarget{classcore_1_1Socket_aa9195676bb7ecbec167ecf5336921cbb}\label{classcore_1_1Socket_aa9195676bb7ecbec167ecf5336921cbb}}
|
|
int {\bfseries get\+Buffer\+Size} ()
|
|
\item
|
|
virtual void \mbox{\hyperlink{classcore_1_1Socket_ac8d6a2c54696eb6fc2024cf6bcf6b4e5}{on\+Data\+Received}} (std\+::string data)
|
|
\begin{DoxyCompactList}\small\item\em Called when data is received from the socket. \end{DoxyCompactList}\item
|
|
\mbox{\Hypertarget{classcore_1_1Socket_ae048b57ac2c34381378f3da0e758b3c8}\label{classcore_1_1Socket_ae048b57ac2c34381378f3da0e758b3c8}}
|
|
virtual void {\bfseries on\+Data\+Received} (coreutils\+::\+ZString \&data)
|
|
\item
|
|
virtual void \mbox{\hyperlink{classcore_1_1Socket_a46ed2e240852d3fa949979ebbc4ac875}{receive\+Data}} (coreutils\+::\+ZString \&buffer)
|
|
\end{DoxyCompactItemize}
|
|
\doxysubsection*{Protected Attributes}
|
|
\begin{DoxyCompactItemize}
|
|
\item
|
|
\mbox{\Hypertarget{classcore_1_1Socket_a3b0b139ac7da581f0d969f6ae9a0c97c}\label{classcore_1_1Socket_a3b0b139ac7da581f0d969f6ae9a0c97c}}
|
|
\mbox{\hyperlink{classcore_1_1EPoll}{EPoll}} \& {\bfseries e\+Poll}
|
|
\end{DoxyCompactItemize}
|
|
|
|
|
|
\doxysubsection{Detailed Description}
|
|
\mbox{\hyperlink{classcore_1_1Socket}{Socket}}
|
|
|
|
The core component to managing a socket.
|
|
|
|
Hooks into the \mbox{\hyperlink{classcore_1_1EPoll}{EPoll}} 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 \mbox{\hyperlink{classcore_1_1EPoll}{EPoll}} object and also provides buffering for output data requests to the socket.
|
|
|
|
A program using a socket object can request to open a socket (network or device) and communicate through the streambuffer interface of the socket object.
|
|
|
|
The socket side of the \mbox{\hyperlink{classcore_1_1Socket}{Socket}} accepts EPOLLIN 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. Only sockets that send events to epoll can be used with this object.
|
|
|
|
When writing to the stream the data is written into a buffer and a EPOLLOUT is scheduled. Upon receiving the EPOLLOUT event then the buffer is written to the socket output.
|
|
|
|
\doxysubsection{Constructor \& Destructor Documentation}
|
|
\mbox{\Hypertarget{classcore_1_1Socket_a4c3f87fd1de3c9eab4bf5efbb30ce87d}\label{classcore_1_1Socket_a4c3f87fd1de3c9eab4bf5efbb30ce87d}}
|
|
\index{core::Socket@{core::Socket}!Socket@{Socket}}
|
|
\index{Socket@{Socket}!core::Socket@{core::Socket}}
|
|
\doxysubsubsection{\texorpdfstring{Socket()}{Socket()}}
|
|
{\footnotesize\ttfamily core\+::\+Socket\+::\+Socket (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{classcore_1_1EPoll}{EPoll}} \&}]{e\+Poll, }\item[{std\+::string}]{text = {\ttfamily \char`\"{}\char`\"{}} }\end{DoxyParamCaption})}
|
|
|
|
Constructor
|
|
|
|
|
|
\begin{DoxyParams}{Parameters}
|
|
{\em e\+Poll} & The \mbox{\hyperlink{classcore_1_1EPoll}{EPoll}} socket descriptor. \\
|
|
\hline
|
|
{\em text} & A title for this socket. \\
|
|
\hline
|
|
\end{DoxyParams}
|
|
\mbox{\Hypertarget{classcore_1_1Socket_aa5003845f8ae464ad2fa206176381be0}\label{classcore_1_1Socket_aa5003845f8ae464ad2fa206176381be0}}
|
|
\index{core::Socket@{core::Socket}!````~Socket@{$\sim$Socket}}
|
|
\index{````~Socket@{$\sim$Socket}!core::Socket@{core::Socket}}
|
|
\doxysubsubsection{\texorpdfstring{$\sim$Socket()}{~Socket()}}
|
|
{\footnotesize\ttfamily core\+::\+Socket\+::$\sim$\+Socket (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [virtual]}}
|
|
|
|
Destructor
|
|
|
|
\doxysubsection{Member Function Documentation}
|
|
\mbox{\Hypertarget{classcore_1_1Socket_a1a045e15fb5851d666a21be05ac4c5d7}\label{classcore_1_1Socket_a1a045e15fb5851d666a21be05ac4c5d7}}
|
|
\index{core::Socket@{core::Socket}!eventReceived@{eventReceived}}
|
|
\index{eventReceived@{eventReceived}!core::Socket@{core::Socket}}
|
|
\doxysubsubsection{\texorpdfstring{eventReceived()}{eventReceived()}}
|
|
{\footnotesize\ttfamily bool core\+::\+Socket\+::event\+Received (\begin{DoxyParamCaption}\item[{struct epoll\+\_\+event}]{event, }\item[{long long}]{event\+Id }\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 BMAEPoll object and should not be called from any user extended classes unless an epoll event is being simulated.
|
|
|
|
The return value of false will delete the socket object causing the destructors to run. The return value of true will enable the socket on e\+Poll to receive more events. \mbox{\Hypertarget{classcore_1_1Socket_ac8d6a2c54696eb6fc2024cf6bcf6b4e5}\label{classcore_1_1Socket_ac8d6a2c54696eb6fc2024cf6bcf6b4e5}}
|
|
\index{core::Socket@{core::Socket}!onDataReceived@{onDataReceived}}
|
|
\index{onDataReceived@{onDataReceived}!core::Socket@{core::Socket}}
|
|
\doxysubsubsection{\texorpdfstring{onDataReceived()}{onDataReceived()}}
|
|
{\footnotesize\ttfamily void core\+::\+Socket\+::on\+Data\+Received (\begin{DoxyParamCaption}\item[{std\+::string}]{data }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [protected]}, {\ttfamily [virtual]}}
|
|
|
|
|
|
|
|
Called when data is received from the socket.
|
|
|
|
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. 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. EPOLLIN
|
|
|
|
|
|
\begin{DoxyParams}{Parameters}
|
|
{\em data} & the data that has been received from the socket. \\
|
|
\hline
|
|
\end{DoxyParams}
|
|
|
|
|
|
Reimplemented in \mbox{\hyperlink{classcore_1_1UDPServerSocket_a41933ca153c854a800e3d047ab18313e}{core\+::\+UDPServer\+Socket}}, and \mbox{\hyperlink{classcore_1_1TCPServer_a276ccbc8cb9b4380ebd78807b97f0159}{core\+::\+TCPServer}}.
|
|
|
|
\mbox{\Hypertarget{classcore_1_1Socket_a81e5ee3e17834166d97c6e8b7dfe0da0}\label{classcore_1_1Socket_a81e5ee3e17834166d97c6e8b7dfe0da0}}
|
|
\index{core::Socket@{core::Socket}!onRegister@{onRegister}}
|
|
\index{onRegister@{onRegister}!core::Socket@{core::Socket}}
|
|
\doxysubsubsection{\texorpdfstring{onRegister()}{onRegister()}}
|
|
{\footnotesize\ttfamily void core\+::\+Socket\+::on\+Register (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [virtual]}}
|
|
|
|
|
|
|
|
Called before the socket has registered with the epoll processing.
|
|
|
|
The on\+Register method is called before the socket is registered with e\+Poll so objects extending the \mbox{\hyperlink{classcore_1_1Socket}{Socket}} definition can initialize the socket before receiving events. Evoked when the descriptor is set using set\+Descriptor for the socket.
|
|
|
|
Reimplemented in \mbox{\hyperlink{classcore_1_1TLSSession_a76cec7cf4851eb27abe77a2339344c6d}{core\+::\+TLSSession}}.
|
|
|
|
\mbox{\Hypertarget{classcore_1_1Socket_ae9be59697c2b2e5efb19aaae3ba943d2}\label{classcore_1_1Socket_ae9be59697c2b2e5efb19aaae3ba943d2}}
|
|
\index{core::Socket@{core::Socket}!onUnregistered@{onUnregistered}}
|
|
\index{onUnregistered@{onUnregistered}!core::Socket@{core::Socket}}
|
|
\doxysubsubsection{\texorpdfstring{onUnregistered()}{onUnregistered()}}
|
|
{\footnotesize\ttfamily void core\+::\+Socket\+::on\+Unregistered (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [virtual]}}
|
|
|
|
|
|
|
|
Called when the socket has finished unregistering for the epoll processing.
|
|
|
|
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{classcore_1_1Socket_a46ed2e240852d3fa949979ebbc4ac875}\label{classcore_1_1Socket_a46ed2e240852d3fa949979ebbc4ac875}}
|
|
\index{core::Socket@{core::Socket}!receiveData@{receiveData}}
|
|
\index{receiveData@{receiveData}!core::Socket@{core::Socket}}
|
|
\doxysubsubsection{\texorpdfstring{receiveData()}{receiveData()}}
|
|
{\footnotesize\ttfamily void core\+::\+Socket\+::receive\+Data (\begin{DoxyParamCaption}\item[{coreutils\+::\+ZString \&}]{buffer }\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. TLS layer overrides this to be able to read from SSL.
|
|
|
|
Reimplemented in \mbox{\hyperlink{classcore_1_1TLSSession_a8507cdcd23ac4b340ce6f6d5f0b26a52}{core\+::\+TLSSession}}.
|
|
|
|
\mbox{\Hypertarget{classcore_1_1Socket_ac44f6ae3196a8a3e09a6a85fcf495762}\label{classcore_1_1Socket_ac44f6ae3196a8a3e09a6a85fcf495762}}
|
|
\index{core::Socket@{core::Socket}!setDescriptor@{setDescriptor}}
|
|
\index{setDescriptor@{setDescriptor}!core::Socket@{core::Socket}}
|
|
\doxysubsubsection{\texorpdfstring{setDescriptor()}{setDescriptor()}}
|
|
{\footnotesize\ttfamily void core\+::\+Socket\+::set\+Descriptor (\begin{DoxyParamCaption}\item[{int}]{descriptor }\end{DoxyParamCaption})}
|
|
|
|
|
|
|
|
Set the descriptor for the socket.
|
|
|
|
set\+Descriptor establishes the file descriptor for the socket and registers the socket on the \mbox{\hyperlink{classcore_1_1EPoll}{EPoll}} controller. set\+Descriptor will invoke the \mbox{\hyperlink{classcore_1_1Socket_a81e5ee3e17834166d97c6e8b7dfe0da0}{on\+Register()}} event. \mbox{\Hypertarget{classcore_1_1Socket_af2d1b6de7a64a9d446b0305b6ec47b31}\label{classcore_1_1Socket_af2d1b6de7a64a9d446b0305b6ec47b31}}
|
|
\index{core::Socket@{core::Socket}!shutdown@{shutdown}}
|
|
\index{shutdown@{shutdown}!core::Socket@{core::Socket}}
|
|
\doxysubsubsection{\texorpdfstring{shutdown()}{shutdown()}}
|
|
{\footnotesize\ttfamily void core\+::\+Socket\+::shutdown (\begin{DoxyParamCaption}\item[{std\+::string}]{text = {\ttfamily \char`\"{}unknown\char`\"{}} }\end{DoxyParamCaption})}
|
|
|
|
Use the \mbox{\hyperlink{classcore_1_1Socket_af2d1b6de7a64a9d446b0305b6ec47b31}{shutdown()}} method to terminate the socket connection and remove resources. This method is provided to ensure that all destructors are called for all inherited objects with a virtual destructor. \mbox{\Hypertarget{classcore_1_1Socket_a4ed587f31d080115c00828f90b1e28bb}\label{classcore_1_1Socket_a4ed587f31d080115c00828f90b1e28bb}}
|
|
\index{core::Socket@{core::Socket}!write@{write}}
|
|
\index{write@{write}!core::Socket@{core::Socket}}
|
|
\doxysubsubsection{\texorpdfstring{write()}{write()}}
|
|
{\footnotesize\ttfamily int core\+::\+Socket\+::write (\begin{DoxyParamCaption}\item[{std\+::string}]{data, }\item[{\mbox{\hyperlink{classcore_1_1Socket}{Socket}} $\ast$}]{sender }\end{DoxyParamCaption})}
|
|
|
|
Write data to the socket.
|
|
|
|
The documentation for this class was generated from the following files\+:\begin{DoxyCompactItemize}
|
|
\item
|
|
Socket.\+h\item
|
|
Socket.\+cpp\end{DoxyCompactItemize}
|