classSocketListener.html 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
  5. <meta http-equiv="X-UA-Compatible" content="IE=9"/>
  6. <meta name="generator" content="Doxygen 1.8.16"/>
  7. <meta name="viewport" content="width=device-width, initial-scale=1"/>
  8. <title>Socket Server: SocketListener Class Reference</title>
  9. <link href="tabs.css" rel="stylesheet" type="text/css"/>
  10. <script type="text/javascript" src="jquery.js"></script>
  11. <script type="text/javascript" src="dynsections.js"></script>
  12. <link href="search/search.css" rel="stylesheet" type="text/css"/>
  13. <script type="text/javascript" src="search/searchdata.js"></script>
  14. <script type="text/javascript" src="search/search.js"></script>
  15. <link href="doxygen.css" rel="stylesheet" type="text/css" />
  16. </head>
  17. <body>
  18. <div id="top"><!-- do not remove this div, it is closed by doxygen! -->
  19. <div id="titlearea">
  20. <table cellspacing="0" cellpadding="0">
  21. <tbody>
  22. <tr style="height: 56px;">
  23. <td id="projectalign" style="padding-left: 0.5em;">
  24. <div id="projectname">Socket Server
  25. </div>
  26. </td>
  27. </tr>
  28. </tbody>
  29. </table>
  30. </div>
  31. <!-- end header part -->
  32. <!-- Generated by Doxygen 1.8.16 -->
  33. <script type="text/javascript">
  34. /* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
  35. var searchBox = new SearchBox("searchBox", "search",false,'Search');
  36. /* @license-end */
  37. </script>
  38. <script type="text/javascript" src="menudata.js"></script>
  39. <script type="text/javascript" src="menu.js"></script>
  40. <script type="text/javascript">
  41. /* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
  42. $(function() {
  43. initMenu('',true,false,'search.php','Search');
  44. $(document).ready(function() { init_search(); });
  45. });
  46. /* @license-end */</script>
  47. <div id="main-nav"></div>
  48. <!-- window showing the filter options -->
  49. <div id="MSearchSelectWindow"
  50. onmouseover="return searchBox.OnSearchSelectShow()"
  51. onmouseout="return searchBox.OnSearchSelectHide()"
  52. onkeydown="return searchBox.OnSearchSelectKey(event)">
  53. </div>
  54. <!-- iframe showing the search results (closed by default) -->
  55. <div id="MSearchResultsWindow">
  56. <iframe src="javascript:void(0)" frameborder="0"
  57. name="MSearchResults" id="MSearchResults">
  58. </iframe>
  59. </div>
  60. </div><!-- top -->
  61. <div class="header">
  62. <div class="summary">
  63. <a href="#nested-classes">Classes</a> &#124;
  64. <a href="#pub-methods">Public Member Functions</a> &#124;
  65. <a href="classSocketListener-members.html">List of all members</a> </div>
  66. <div class="headertitle">
  67. <div class="title">SocketListener Class Reference</div> </div>
  68. </div><!--header-->
  69. <div class="contents">
  70. <p><code>#include &lt;<a class="el" href="socket__listener_8h_source.html">socket_listener.h</a>&gt;</code></p>
  71. <div class="dynheader">
  72. Inheritance diagram for SocketListener:</div>
  73. <div class="dyncontent">
  74. <div class="center">
  75. <img src="classSocketListener.png" usemap="#SocketListener_map" alt=""/>
  76. <map id="SocketListener_map" name="SocketListener_map">
  77. <area href="classSendInterface.html" alt="SendInterface" shape="rect" coords="0,0,95,24"/>
  78. </map>
  79. </div></div>
  80. <table class="memberdecls">
  81. <tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="nested-classes"></a>
  82. Classes</h2></td></tr>
  83. <tr class="memitem:"><td class="memItemLeft" align="right" valign="top">class &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classSocketListener_1_1MessageHandler.html">MessageHandler</a></td></tr>
  84. <tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
  85. </table><table class="memberdecls">
  86. <tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-methods"></a>
  87. Public Member Functions</h2></td></tr>
  88. <tr class="memitem:af957cc189529396c90aae6aaa7cf0c69"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classSocketListener.html#af957cc189529396c90aae6aaa7cf0c69">SocketListener</a> (std::string ipAddress, int port)</td></tr>
  89. <tr class="separator:af957cc189529396c90aae6aaa7cf0c69"><td class="memSeparator" colspan="2">&#160;</td></tr>
  90. <tr class="memitem:a061fcf8b47360d4410fcbd2af1e34b7a"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classSocketListener.html#a061fcf8b47360d4410fcbd2af1e34b7a">~SocketListener</a> ()</td></tr>
  91. <tr class="separator:a061fcf8b47360d4410fcbd2af1e34b7a"><td class="memSeparator" colspan="2">&#160;</td></tr>
  92. <tr class="memitem:a47a9f1bbbe160e06bb8b97118ed96c57"><td class="memItemLeft" align="right" valign="top">virtual void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classSocketListener.html#a47a9f1bbbe160e06bb8b97118ed96c57">sendMessage</a> (int client_socket_fd, std::shared_ptr&lt; char[]&gt; buffer) override</td></tr>
  93. <tr class="separator:a47a9f1bbbe160e06bb8b97118ed96c57"><td class="memSeparator" colspan="2">&#160;</td></tr>
  94. <tr class="memitem:a4d1d1dba518b37ebb60151a17e7cb238"><td class="memItemLeft" align="right" valign="top"><a class="el" href="classSocketListener_1_1MessageHandler.html">MessageHandler</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classSocketListener.html#a4d1d1dba518b37ebb60151a17e7cb238">createMessageHandler</a> (std::function&lt; void()&gt; cb)</td></tr>
  95. <tr class="separator:a4d1d1dba518b37ebb60151a17e7cb238"><td class="memSeparator" colspan="2">&#160;</td></tr>
  96. <tr class="memitem:ac15f68258fc51e00de3ecb8fad336773"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classSocketListener.html#ac15f68258fc51e00de3ecb8fad336773">init</a> ()</td></tr>
  97. <tr class="separator:ac15f68258fc51e00de3ecb8fad336773"><td class="memSeparator" colspan="2">&#160;</td></tr>
  98. <tr class="memitem:a40a414e609215442d19ca6c58d4a2302"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classSocketListener.html#a40a414e609215442d19ca6c58d4a2302">run</a> ()</td></tr>
  99. <tr class="separator:a40a414e609215442d19ca6c58d4a2302"><td class="memSeparator" colspan="2">&#160;</td></tr>
  100. <tr class="memitem:a2b2ffb4e2977a2f3e000151dd7b228ad"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classSocketListener.html#a2b2ffb4e2977a2f3e000151dd7b228ad">cleanup</a> ()</td></tr>
  101. <tr class="separator:a2b2ffb4e2977a2f3e000151dd7b228ad"><td class="memSeparator" colspan="2">&#160;</td></tr>
  102. </table>
  103. <h2 class="groupheader">Constructor &amp; Destructor Documentation</h2>
  104. <a id="af957cc189529396c90aae6aaa7cf0c69"></a>
  105. <h2 class="memtitle"><span class="permalink"><a href="#af957cc189529396c90aae6aaa7cf0c69">&#9670;&nbsp;</a></span>SocketListener()</h2>
  106. <div class="memitem">
  107. <div class="memproto">
  108. <table class="memname">
  109. <tr>
  110. <td class="memname">SocketListener::SocketListener </td>
  111. <td>(</td>
  112. <td class="paramtype">std::string&#160;</td>
  113. <td class="paramname"><em>ip_address</em>, </td>
  114. </tr>
  115. <tr>
  116. <td class="paramkey"></td>
  117. <td></td>
  118. <td class="paramtype">int&#160;</td>
  119. <td class="paramname"><em>port</em>&#160;</td>
  120. </tr>
  121. <tr>
  122. <td></td>
  123. <td>)</td>
  124. <td></td><td></td>
  125. </tr>
  126. </table>
  127. </div><div class="memdoc">
  128. <p>Constructor Initialize with ip_address, port and message_handler </p>
  129. </div>
  130. </div>
  131. <a id="a061fcf8b47360d4410fcbd2af1e34b7a"></a>
  132. <h2 class="memtitle"><span class="permalink"><a href="#a061fcf8b47360d4410fcbd2af1e34b7a">&#9670;&nbsp;</a></span>~SocketListener()</h2>
  133. <div class="memitem">
  134. <div class="memproto">
  135. <table class="memname">
  136. <tr>
  137. <td class="memname">SocketListener::~SocketListener </td>
  138. <td>(</td>
  139. <td class="paramname"></td><td>)</td>
  140. <td></td>
  141. </tr>
  142. </table>
  143. </div><div class="memdoc">
  144. <p>Destructor TODO: Determine if we should make buffer a class member </p>
  145. </div>
  146. </div>
  147. <h2 class="groupheader">Member Function Documentation</h2>
  148. <a id="a2b2ffb4e2977a2f3e000151dd7b228ad"></a>
  149. <h2 class="memtitle"><span class="permalink"><a href="#a2b2ffb4e2977a2f3e000151dd7b228ad">&#9670;&nbsp;</a></span>cleanup()</h2>
  150. <div class="memitem">
  151. <div class="memproto">
  152. <table class="memname">
  153. <tr>
  154. <td class="memname">void SocketListener::cleanup </td>
  155. <td>(</td>
  156. <td class="paramname"></td><td>)</td>
  157. <td></td>
  158. </tr>
  159. </table>
  160. </div><div class="memdoc">
  161. <p>Perform any cleanup work</p>
  162. <p>cleanUp @method TODO: Determine if we should be cleaning up buffer memory </p>
  163. </div>
  164. </div>
  165. <a id="a4d1d1dba518b37ebb60151a17e7cb238"></a>
  166. <h2 class="memtitle"><span class="permalink"><a href="#a4d1d1dba518b37ebb60151a17e7cb238">&#9670;&nbsp;</a></span>createMessageHandler()</h2>
  167. <div class="memitem">
  168. <div class="memproto">
  169. <table class="memname">
  170. <tr>
  171. <td class="memname"><a class="el" href="classSocketListener_1_1MessageHandler.html">SocketListener::MessageHandler</a> SocketListener::createMessageHandler </td>
  172. <td>(</td>
  173. <td class="paramtype">std::function&lt; void()&gt;&#160;</td>
  174. <td class="paramname"><em>cb</em></td><td>)</td>
  175. <td></td>
  176. </tr>
  177. </table>
  178. </div><div class="memdoc">
  179. </div>
  180. </div>
  181. <a id="ac15f68258fc51e00de3ecb8fad336773"></a>
  182. <h2 class="memtitle"><span class="permalink"><a href="#ac15f68258fc51e00de3ecb8fad336773">&#9670;&nbsp;</a></span>init()</h2>
  183. <div class="memitem">
  184. <div class="memproto">
  185. <table class="memname">
  186. <tr>
  187. <td class="memname">bool SocketListener::init </td>
  188. <td>(</td>
  189. <td class="paramname"></td><td>)</td>
  190. <td></td>
  191. </tr>
  192. </table>
  193. </div><div class="memdoc">
  194. <p>Perform intialization work</p>
  195. <p>init TODO: Initialize buffer memory, if buffer is to be a class member </p>
  196. </div>
  197. </div>
  198. <a id="a40a414e609215442d19ca6c58d4a2302"></a>
  199. <h2 class="memtitle"><span class="permalink"><a href="#a40a414e609215442d19ca6c58d4a2302">&#9670;&nbsp;</a></span>run()</h2>
  200. <div class="memitem">
  201. <div class="memproto">
  202. <table class="memname">
  203. <tr>
  204. <td class="memname">void SocketListener::run </td>
  205. <td>(</td>
  206. <td class="paramname"></td><td>)</td>
  207. <td></td>
  208. </tr>
  209. </table>
  210. </div><div class="memdoc">
  211. <p>Main message loop</p>
  212. <p>run @method Main message loop TODO: Implement multithreading </p>
  213. </div>
  214. </div>
  215. <a id="a47a9f1bbbe160e06bb8b97118ed96c57"></a>
  216. <h2 class="memtitle"><span class="permalink"><a href="#a47a9f1bbbe160e06bb8b97118ed96c57">&#9670;&nbsp;</a></span>sendMessage()</h2>
  217. <div class="memitem">
  218. <div class="memproto">
  219. <table class="mlabels">
  220. <tr>
  221. <td class="mlabels-left">
  222. <table class="memname">
  223. <tr>
  224. <td class="memname">void SocketListener::sendMessage </td>
  225. <td>(</td>
  226. <td class="paramtype">int&#160;</td>
  227. <td class="paramname"><em>client_socket_fd</em>, </td>
  228. </tr>
  229. <tr>
  230. <td class="paramkey"></td>
  231. <td></td>
  232. <td class="paramtype">std::shared_ptr&lt; char[]&gt;&#160;</td>
  233. <td class="paramname"><em>s_ptr</em>&#160;</td>
  234. </tr>
  235. <tr>
  236. <td></td>
  237. <td>)</td>
  238. <td></td><td></td>
  239. </tr>
  240. </table>
  241. </td>
  242. <td class="mlabels-right">
  243. <span class="mlabels"><span class="mlabel">override</span><span class="mlabel">virtual</span></span> </td>
  244. </tr>
  245. </table>
  246. </div><div class="memdoc">
  247. <p>Send a message to a client socket described by its file descriptor </p><dl class="params"><dt>Parameters</dt><dd>
  248. <table class="params">
  249. <tr><td class="paramdir">[in]</td><td class="paramname">{int}</td><td>client_socket_fd The client socket file descriptor </td></tr>
  250. <tr><td class="paramdir">[in]</td><td class="paramname">{std::string}</td><td>The message to be sent</td></tr>
  251. </table>
  252. </dd>
  253. </dl>
  254. <p>sendMessage @method Send a null-terminated array of characters, supplied as a const char pointer, to a client socket described by its file descriptor </p>
  255. <p>Implements <a class="el" href="classSendInterface.html#a2475e2b3ffaf5591b6e73d66d6a0a308">SendInterface</a>.</p>
  256. </div>
  257. </div>
  258. <hr/>The documentation for this class was generated from the following files:<ul>
  259. <li>headers/<a class="el" href="socket__listener_8h_source.html">socket_listener.h</a></li>
  260. <li><a class="el" href="socket__listener_8cpp.html">socket_listener.cpp</a></li>
  261. </ul>
  262. </div><!-- contents -->
  263. <!-- start footer part -->
  264. <hr class="footer"/><address class="footer"><small>
  265. Generated by &#160;<a href="http://www.doxygen.org/index.html">
  266. <img class="footer" src="doxygen.png" alt="doxygen"/>
  267. </a> 1.8.16
  268. </small></address>
  269. </body>
  270. </html>