source: flair-dev/trunk/doc/Flair/_tcp_socket_8h_source.html@ 31

Last change on this file since 31 was 28, checked in by Sanahuja Guillaume, 8 years ago

m

File size: 17.3 KB
Line 
1<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://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.9.1"/>
7<title>Flair: TcpSocket.h Source File</title>
8<link href="tabs.css" rel="stylesheet" type="text/css"/>
9<script type="text/javascript" src="jquery.js"></script>
10<script type="text/javascript" src="dynsections.js"></script>
11<link href="navtree.css" rel="stylesheet" type="text/css"/>
12<script type="text/javascript" src="resize.js"></script>
13<script type="text/javascript" src="navtreedata.js"></script>
14<script type="text/javascript" src="navtree.js"></script>
15<script type="text/javascript">
16 $(document).ready(initResizable);
17 $(window).load(resizeHeight);
18</script>
19<link href="search/search.css" rel="stylesheet" type="text/css"/>
20<script type="text/javascript" src="search/searchdata.js"></script>
21<script type="text/javascript" src="search/search.js"></script>
22<script type="text/javascript">
23 $(document).ready(function() { init_search(); });
24</script>
25<link href="doxygen.css" rel="stylesheet" type="text/css" />
26</head>
27<body>
28<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
29<div id="titlearea">
30<table cellspacing="0" cellpadding="0">
31 <tbody>
32 <tr style="height: 56px;">
33 <td id="projectlogo"><img alt="Logo" src="logo_hds.png"/></td>
34 <td style="padding-left: 0.5em;">
35 <div id="projectname">Flair
36 </div>
37 <div id="projectbrief">Framework Libre Air</div>
38 </td>
39 </tr>
40 </tbody>
41</table>
42</div>
43<!-- end header part -->
44<!-- Generated by Doxygen 1.8.9.1 -->
45<script type="text/javascript">
46var searchBox = new SearchBox("searchBox", "search",false,'Search');
47</script>
48 <div id="navrow1" class="tabs">
49 <ul class="tablist">
50 <li><a href="index.html"><span>Main&#160;Page</span></a></li>
51 <li><a href="namespaces.html"><span>Namespaces</span></a></li>
52 <li><a href="annotated.html"><span>Classes</span></a></li>
53 <li class="current"><a href="files.html"><span>Files</span></a></li>
54 <li>
55 <div id="MSearchBox" class="MSearchBoxInactive">
56 <span class="left">
57 <img id="MSearchSelect" src="search/mag_sel.png"
58 onmouseover="return searchBox.OnSearchSelectShow()"
59 onmouseout="return searchBox.OnSearchSelectHide()"
60 alt=""/>
61 <input type="text" id="MSearchField" value="Search" accesskey="S"
62 onfocus="searchBox.OnSearchFieldFocus(true)"
63 onblur="searchBox.OnSearchFieldFocus(false)"
64 onkeyup="searchBox.OnSearchFieldChange(event)"/>
65 </span><span class="right">
66 <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
67 </span>
68 </div>
69 </li>
70 </ul>
71 </div>
72 <div id="navrow2" class="tabs2">
73 <ul class="tablist">
74 <li><a href="files.html"><span>File&#160;List</span></a></li>
75 </ul>
76 </div>
77</div><!-- top -->
78<div id="side-nav" class="ui-resizable side-nav-resizable">
79 <div id="nav-tree">
80 <div id="nav-tree-contents">
81 <div id="nav-sync" class="sync"></div>
82 </div>
83 </div>
84 <div id="splitbar" style="-moz-user-select:none;"
85 class="ui-resizable-handle">
86 </div>
87</div>
88<script type="text/javascript">
89$(document).ready(function(){initNavTree('_tcp_socket_8h_source.html','');});
90</script>
91<div id="doc-content">
92<!-- window showing the filter options -->
93<div id="MSearchSelectWindow"
94 onmouseover="return searchBox.OnSearchSelectShow()"
95 onmouseout="return searchBox.OnSearchSelectHide()"
96 onkeydown="return searchBox.OnSearchSelectKey(event)">
97</div>
98
99<!-- iframe showing the search results (closed by default) -->
100<div id="MSearchResultsWindow">
101<iframe src="javascript:void(0)" frameborder="0"
102 name="MSearchResults" id="MSearchResults">
103</iframe>
104</div>
105
106<div class="header">
107 <div class="headertitle">
108<div class="title">TcpSocket.h</div> </div>
109</div><!--header-->
110<div class="contents">
111<a href="_tcp_socket_8h.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno"> 1</span>&#160;<span class="comment">// %flair:license{</span></div>
112<div class="line"><a name="l00002"></a><span class="lineno"> 2</span>&#160;<span class="comment">// This file is part of the Flair framework distributed under the</span></div>
113<div class="line"><a name="l00003"></a><span class="lineno"> 3</span>&#160;<span class="comment">// CECILL-C License, Version 1.0.</span></div>
114<div class="line"><a name="l00004"></a><span class="lineno"> 4</span>&#160;<span class="comment">// %flair:license}</span></div>
115<div class="line"><a name="l00013"></a><span class="lineno"> 13</span>&#160;<span class="comment"></span><span class="preprocessor">#ifndef TCPSOCKET_H</span></div>
116<div class="line"><a name="l00014"></a><span class="lineno"> 14</span>&#160;<span class="preprocessor">#define TCPSOCKET_H</span></div>
117<div class="line"><a name="l00015"></a><span class="lineno"> 15</span>&#160;</div>
118<div class="line"><a name="l00016"></a><span class="lineno"> 16</span>&#160;<span class="preprocessor">#include &lt;<a class="code" href="_connected_socket_8h.html">ConnectedSocket.h</a>&gt;</span></div>
119<div class="line"><a name="l00017"></a><span class="lineno"> 17</span>&#160;</div>
120<div class="line"><a name="l00018"></a><span class="lineno"> 18</span>&#160;<span class="keyword">namespace </span><a class="code" href="namespaceflair.html">flair</a> {</div>
121<div class="line"><a name="l00019"></a><span class="lineno"> 19</span>&#160;<span class="keyword">namespace </span>core {</div>
122<div class="line"><a name="l00025"></a><span class="lineno"><a class="line" href="classflair_1_1core_1_1_tcp_socket.html"> 25</a></span>&#160;<span class="keyword">class </span><a class="code" href="classflair_1_1core_1_1_tcp_socket.html">TcpSocket</a> : <span class="keyword">public</span> <a class="code" href="classflair_1_1core_1_1_connected_socket.html">ConnectedSocket</a> {</div>
123<div class="line"><a name="l00026"></a><span class="lineno"> 26</span>&#160;<span class="keyword">public</span>:</div>
124<div class="line"><a name="l00027"></a><span class="lineno"> 27</span>&#160; <a class="code" href="classflair_1_1core_1_1_tcp_socket.html">TcpSocket</a>(<span class="keyword">const</span> <a class="code" href="classflair_1_1core_1_1_object.html">Object</a> *parent, <span class="keyword">const</span> std::string name,</div>
125<div class="line"><a name="l00028"></a><span class="lineno"> 28</span>&#160; <span class="keywordtype">bool</span> blockOnSend = <span class="keyword">false</span>, <span class="keywordtype">bool</span> blockOnReceive = <span class="keyword">true</span>);</div>
126<div class="line"><a name="l00029"></a><span class="lineno"> 29</span>&#160; ~<a class="code" href="classflair_1_1core_1_1_tcp_socket.html">TcpSocket</a>();</div>
127<div class="line"><a name="l00030"></a><span class="lineno"> 30</span>&#160; <span class="keywordtype">void</span> <a class="code" href="classflair_1_1core_1_1_tcp_socket.html#a7eaffe48d70e5119182bdb5846c6889d">Listen</a>(<span class="keyword">const</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> port, <span class="keyword">const</span> std::string localAddress = <span class="stringliteral">&quot;ANY&quot;</span>);</div>
128<div class="line"><a name="l00031"></a><span class="lineno"> 31</span>&#160; <a class="code" href="classflair_1_1core_1_1_tcp_socket.html">TcpSocket</a> *<a class="code" href="classflair_1_1core_1_1_tcp_socket.html#a55d90b894a14900d2a84a7772124727d">Accept</a>(</div>
129<div class="line"><a name="l00032"></a><span class="lineno"> 32</span>&#160; <a class="code" href="namespaceflair_1_1core.html#acc0fa041e08ecf73b2d1d723c339a736">Time</a> timeout = 0); <span class="comment">// should throw an exception if not a listening socket</span></div>
130<div class="line"><a name="l00033"></a><span class="lineno"> 33</span>&#160; <span class="keywordtype">bool</span> <a class="code" href="classflair_1_1core_1_1_tcp_socket.html#ac87b68e327a73dada17b3d93dab7929c">Connect</a>(<span class="keyword">const</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> distantPort, <span class="keyword">const</span> std::string distantAddress,</div>
131<div class="line"><a name="l00034"></a><span class="lineno"> 34</span>&#160; <a class="code" href="namespaceflair_1_1core.html#acc0fa041e08ecf73b2d1d723c339a736">Time</a> timeout = 0); <span class="comment">// timeout in milliseconds</span></div>
132<div class="line"><a name="l00035"></a><span class="lineno"> 35</span>&#160; ssize_t <a class="code" href="classflair_1_1core_1_1_tcp_socket.html#aaca9be5ab271cef04af09219ff262f38">SendMessage</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *message, <span class="keywordtype">size_t</span> message_len,</div>
133<div class="line"><a name="l00036"></a><span class="lineno"> 36</span>&#160; <a class="code" href="namespaceflair_1_1core.html#acc0fa041e08ecf73b2d1d723c339a736">Time</a> timeout = 0); <span class="comment">// timeout in milliseconds</span></div>
134<div class="line"><a name="l00037"></a><span class="lineno"> 37</span>&#160; ssize_t <a class="code" href="classflair_1_1core_1_1_tcp_socket.html#ad7e7cf859d7cbe230a33f90c8c1bcfc2">RecvMessage</a>(<span class="keywordtype">char</span> *buf, <span class="keywordtype">size_t</span> buf_len,</div>
135<div class="line"><a name="l00038"></a><span class="lineno"> 38</span>&#160; <a class="code" href="namespaceflair_1_1core.html#acc0fa041e08ecf73b2d1d723c339a736">Time</a> timeout = 0); <span class="comment">// timeout in milliseconds</span></div>
136<div class="line"><a name="l00039"></a><span class="lineno"> 39</span>&#160;</div>
137<div class="line"><a name="l00040"></a><span class="lineno"> 40</span>&#160; uint16_t <a class="code" href="classflair_1_1core_1_1_tcp_socket.html#a94921895eb0b474e967d611d78d630e2">NetworkToHost16</a>(uint16_t data);</div>
138<div class="line"><a name="l00041"></a><span class="lineno"> 41</span>&#160; uint16_t HostToNetwork16(uint16_t data);</div>
139<div class="line"><a name="l00042"></a><span class="lineno"> 42</span>&#160; uint32_t NetworkToHost32(uint32_t data);</div>
140<div class="line"><a name="l00043"></a><span class="lineno"> 43</span>&#160; uint32_t HostToNetwork32(uint32_t data);</div>
141<div class="line"><a name="l00044"></a><span class="lineno"> 44</span>&#160;</div>
142<div class="line"><a name="l00045"></a><span class="lineno"> 45</span>&#160;<span class="keyword">private</span>:</div>
143<div class="line"><a name="l00046"></a><span class="lineno"> 46</span>&#160; <span class="keywordtype">int</span> socket; <span class="comment">// socket file descriptor</span></div>
144<div class="line"><a name="l00047"></a><span class="lineno"> 47</span>&#160; <span class="keywordtype">bool</span> blockOnSend;</div>
145<div class="line"><a name="l00048"></a><span class="lineno"> 48</span>&#160; <span class="keywordtype">bool</span> blockOnReceive;</div>
146<div class="line"><a name="l00049"></a><span class="lineno"> 49</span>&#160; <span class="keywordtype">bool</span> isConnected;</div>
147<div class="line"><a name="l00050"></a><span class="lineno"> 50</span>&#160; <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> distantPort;</div>
148<div class="line"><a name="l00051"></a><span class="lineno"> 51</span>&#160; std::string distantAddress;</div>
149<div class="line"><a name="l00052"></a><span class="lineno"> 52</span>&#160;};</div>
150<div class="line"><a name="l00053"></a><span class="lineno"> 53</span>&#160;</div>
151<div class="line"><a name="l00054"></a><span class="lineno"> 54</span>&#160;} <span class="comment">// end namespace core</span></div>
152<div class="line"><a name="l00055"></a><span class="lineno"> 55</span>&#160;} <span class="comment">// end namespace flair</span></div>
153<div class="line"><a name="l00056"></a><span class="lineno"> 56</span>&#160;</div>
154<div class="line"><a name="l00057"></a><span class="lineno"> 57</span>&#160;<span class="preprocessor">#endif // TCPSOCKET_H</span></div>
155<div class="ttc" id="classflair_1_1core_1_1_connected_socket_html"><div class="ttname"><a href="classflair_1_1core_1_1_connected_socket.html">flair::core::ConnectedSocket</a></div><div class="ttdoc">Interface class encapsulating a connected socket. Preserves packets order and guaranty delivery...</div><div class="ttdef"><b>Definition:</b> ConnectedSocket.h:27</div></div>
156<div class="ttc" id="classflair_1_1core_1_1_object_html"><div class="ttname"><a href="classflair_1_1core_1_1_object.html">flair::core::Object</a></div><div class="ttdoc">Base class for all Framework&#39;s classes. </div><div class="ttdef"><b>Definition:</b> Object.h:77</div></div>
157<div class="ttc" id="namespaceflair_html"><div class="ttname"><a href="namespaceflair.html">flair</a></div><div class="ttdoc">namespace of the flair Framework </div><div class="ttdef"><b>Definition:</b> Ahrs.h:19</div></div>
158<div class="ttc" id="namespaceflair_1_1core_html_acc0fa041e08ecf73b2d1d723c339a736"><div class="ttname"><a href="namespaceflair_1_1core.html#acc0fa041e08ecf73b2d1d723c339a736">flair::core::Time</a></div><div class="ttdeci">unsigned long long Time</div><div class="ttdoc">Time definition, in ns. </div><div class="ttdef"><b>Definition:</b> Object.h:49</div></div>
159<div class="ttc" id="classflair_1_1core_1_1_tcp_socket_html"><div class="ttname"><a href="classflair_1_1core_1_1_tcp_socket.html">flair::core::TcpSocket</a></div><div class="ttdoc">Class encapsulating a TCP socket. </div><div class="ttdef"><b>Definition:</b> TcpSocket.h:25</div></div>
160<div class="ttc" id="_connected_socket_8h_html"><div class="ttname"><a href="_connected_socket_8h.html">ConnectedSocket.h</a></div><div class="ttdoc">Class defining a socket working in connected mode. </div></div>
161<div class="ttc" id="classflair_1_1core_1_1_tcp_socket_html_ac87b68e327a73dada17b3d93dab7929c"><div class="ttname"><a href="classflair_1_1core_1_1_tcp_socket.html#ac87b68e327a73dada17b3d93dab7929c">flair::core::TcpSocket::Connect</a></div><div class="ttdeci">bool Connect(const unsigned int distantPort, const std::string distantAddress, Time timeout=0)</div><div class="ttdoc">Returns a socket connected to a distant host. </div></div>
162<div class="ttc" id="classflair_1_1core_1_1_tcp_socket_html_ad7e7cf859d7cbe230a33f90c8c1bcfc2"><div class="ttname"><a href="classflair_1_1core_1_1_tcp_socket.html#ad7e7cf859d7cbe230a33f90c8c1bcfc2">flair::core::TcpSocket::RecvMessage</a></div><div class="ttdeci">ssize_t RecvMessage(char *buf, size_t buf_len, Time timeout=0)</div><div class="ttdoc">Receive a message. </div></div>
163<div class="ttc" id="classflair_1_1core_1_1_tcp_socket_html_a7eaffe48d70e5119182bdb5846c6889d"><div class="ttname"><a href="classflair_1_1core_1_1_tcp_socket.html#a7eaffe48d70e5119182bdb5846c6889d">flair::core::TcpSocket::Listen</a></div><div class="ttdeci">void Listen(const unsigned int port, const std::string localAddress=&quot;ANY&quot;)</div><div class="ttdoc">Returns a socket which listens on a specific port/address. </div></div>
164<div class="ttc" id="classflair_1_1core_1_1_tcp_socket_html_a94921895eb0b474e967d611d78d630e2"><div class="ttname"><a href="classflair_1_1core_1_1_tcp_socket.html#a94921895eb0b474e967d611d78d630e2">flair::core::TcpSocket::NetworkToHost16</a></div><div class="ttdeci">uint16_t NetworkToHost16(uint16_t data)</div><div class="ttdoc">! See Socket.h for a more generic implementation of network/host endianness </div></div>
165<div class="ttc" id="classflair_1_1core_1_1_tcp_socket_html_aaca9be5ab271cef04af09219ff262f38"><div class="ttname"><a href="classflair_1_1core_1_1_tcp_socket.html#aaca9be5ab271cef04af09219ff262f38">flair::core::TcpSocket::SendMessage</a></div><div class="ttdeci">ssize_t SendMessage(const char *message, size_t message_len, Time timeout=0)</div><div class="ttdoc">Send a message. </div></div>
166<div class="ttc" id="classflair_1_1core_1_1_tcp_socket_html_a55d90b894a14900d2a84a7772124727d"><div class="ttname"><a href="classflair_1_1core_1_1_tcp_socket.html#a55d90b894a14900d2a84a7772124727d">flair::core::TcpSocket::Accept</a></div><div class="ttdeci">TcpSocket * Accept(Time timeout=0)</div><div class="ttdoc">Returns a socket on a new incoming connexion. </div></div>
167</div><!-- fragment --></div><!-- contents -->
168</div><!-- doc-content -->
169<!-- start footer part -->
170<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
171 <ul>
172 <li class="navelem"><a class="el" href="dir_33c2ee9b1665499374b4225c427cf176.html">igep</a></li><li class="navelem"><a class="el" href="dir_f1fe274389177bd7e17de7949c4ffada.html">flair-src</a></li><li class="navelem"><a class="el" href="dir_3ef62148cf94871b4b6ee5d6e3a989c1.html">lib</a></li><li class="navelem"><a class="el" href="dir_97265977dbbd48c696782ccac102bad5.html">FlairCore</a></li><li class="navelem"><a class="el" href="dir_6c198461db290ac9abcdd44184573216.html">src</a></li><li class="navelem"><a class="el" href="_tcp_socket_8h.html">TcpSocket.h</a></li>
173 <li class="footer">Generated on Thu Jul 21 2016 13:33:02 for Flair by
174 <a href="http://www.doxygen.org/index.html">
175 <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.9.1 </li>
176 </ul>
177</div>
178</body>
179</html>
Note: See TracBrowser for help on using the repository browser.