<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> <meta http-equiv="X-UA-Compatible" content="IE=9"/> <meta name="generator" content="Doxygen 1.8.5"/> <title>PolarSSL v1.3.8: net.h Source File</title> <link href="tabs.css" rel="stylesheet" type="text/css"/> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript" src="dynsections.js"></script> <link href="doxygen.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="top"><!-- do not remove this div, it is closed by doxygen! --> <div id="titlearea"> <table cellspacing="0" cellpadding="0"> <tbody> <tr style="height: 56px;"> <td style="padding-left: 0.5em;"> <div id="projectname">PolarSSL v1.3.8 </div> </td> </tr> </tbody> </table> </div> <!-- end header part --> <!-- Generated by Doxygen 1.8.5 --> <div id="navrow1" class="tabs"> <ul class="tablist"> <li><a href="index.html"><span>Main Page</span></a></li> <li><a href="modules.html"><span>Modules</span></a></li> <li><a href="annotated.html"><span>Data Structures</span></a></li> <li class="current"><a href="files.html"><span>Files</span></a></li> </ul> </div> <div id="navrow2" class="tabs2"> <ul class="tablist"> <li><a href="files.html"><span>File List</span></a></li> <li><a href="globals.html"><span>Globals</span></a></li> </ul> </div> <div id="nav-path" class="navpath"> <ul> <li class="navelem"><a class="el" href="dir_6a9bbd12bf4e19a18c45e270f8fae3fd.html">include</a></li><li class="navelem"><a class="el" href="dir_04272d44da4745cf8b8bfc767d6c6523.html">polarssl</a></li> </ul> </div> </div><!-- top --> <div class="header"> <div class="headertitle"> <div class="title">net.h</div> </div> </div><!--header--> <div class="contents"> <a href="net_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> </div> <div class="line"><a name="l00027"></a><span class="lineno"> 27</span> <span class="preprocessor">#ifndef POLARSSL_NET_H</span></div> <div class="line"><a name="l00028"></a><span class="lineno"> 28</span> <span class="preprocessor"></span><span class="preprocessor">#define POLARSSL_NET_H</span></div> <div class="line"><a name="l00029"></a><span class="lineno"> 29</span> <span class="preprocessor"></span></div> <div class="line"><a name="l00030"></a><span class="lineno"> 30</span> <span class="preprocessor">#include <string.h></span></div> <div class="line"><a name="l00031"></a><span class="lineno"> 31</span> </div> <div class="line"><a name="l00032"></a><span class="lineno"><a class="line" href="net_8h.html#a8b8dc4d3104b157a2ade8da7831f48f1"> 32</a></span> <span class="preprocessor">#define POLARSSL_ERR_NET_UNKNOWN_HOST -0x0056 </span></div> <div class="line"><a name="l00033"></a><span class="lineno"><a class="line" href="net_8h.html#aec186e276d741e5aad9d8b4cd7ab0efd"> 33</a></span> <span class="preprocessor">#define POLARSSL_ERR_NET_SOCKET_FAILED -0x0042 </span></div> <div class="line"><a name="l00034"></a><span class="lineno"><a class="line" href="net_8h.html#aa316f63c8e1deda24d3ae1d146854474"> 34</a></span> <span class="preprocessor">#define POLARSSL_ERR_NET_CONNECT_FAILED -0x0044 </span></div> <div class="line"><a name="l00035"></a><span class="lineno"><a class="line" href="net_8h.html#a14395a416f051e26a9918052614b34d8"> 35</a></span> <span class="preprocessor">#define POLARSSL_ERR_NET_BIND_FAILED -0x0046 </span></div> <div class="line"><a name="l00036"></a><span class="lineno"><a class="line" href="net_8h.html#a943010f94195f2f283a2b3d6ccea5422"> 36</a></span> <span class="preprocessor">#define POLARSSL_ERR_NET_LISTEN_FAILED -0x0048 </span></div> <div class="line"><a name="l00037"></a><span class="lineno"><a class="line" href="net_8h.html#ad82bbf5012b60516118c5b85e4a73db9"> 37</a></span> <span class="preprocessor">#define POLARSSL_ERR_NET_ACCEPT_FAILED -0x004A </span></div> <div class="line"><a name="l00038"></a><span class="lineno"><a class="line" href="net_8h.html#a03130c59c475bf1e8a89cf97c28972c6"> 38</a></span> <span class="preprocessor">#define POLARSSL_ERR_NET_RECV_FAILED -0x004C </span></div> <div class="line"><a name="l00039"></a><span class="lineno"><a class="line" href="net_8h.html#a6a6129076b6fefa2d730b9173710f1fe"> 39</a></span> <span class="preprocessor">#define POLARSSL_ERR_NET_SEND_FAILED -0x004E </span></div> <div class="line"><a name="l00040"></a><span class="lineno"><a class="line" href="net_8h.html#ab25ddd7b1e424e1168226dd268259360"> 40</a></span> <span class="preprocessor">#define POLARSSL_ERR_NET_CONN_RESET -0x0050 </span></div> <div class="line"><a name="l00041"></a><span class="lineno"><a class="line" href="net_8h.html#a5f74d0f93745d7b4a7d46a6b78c0fb4a"> 41</a></span> <span class="preprocessor">#define POLARSSL_ERR_NET_WANT_READ -0x0052 </span></div> <div class="line"><a name="l00042"></a><span class="lineno"><a class="line" href="net_8h.html#a714269000de1543b4f4a3e8d6622a979"> 42</a></span> <span class="preprocessor">#define POLARSSL_ERR_NET_WANT_WRITE -0x0054 </span></div> <div class="line"><a name="l00044"></a><span class="lineno"><a class="line" href="net_8h.html#adc2420949d7ec4d71bc892bcdb9d1875"> 44</a></span> <span class="preprocessor">#define POLARSSL_NET_LISTEN_BACKLOG 10 </span></div> <div class="line"><a name="l00046"></a><span class="lineno"> 46</span> <span class="preprocessor">#ifdef __cplusplus</span></div> <div class="line"><a name="l00047"></a><span class="lineno"> 47</span> <span class="preprocessor"></span><span class="keyword">extern</span> <span class="stringliteral">"C"</span> {</div> <div class="line"><a name="l00048"></a><span class="lineno"> 48</span> <span class="preprocessor">#endif</span></div> <div class="line"><a name="l00049"></a><span class="lineno"> 49</span> <span class="preprocessor"></span></div> <div class="line"><a name="l00062"></a><span class="lineno"> 62</span> <span class="keywordtype">int</span> <a class="code" href="net_8h.html#a49c549b21517d6f905eb9845224f2773">net_connect</a>( <span class="keywordtype">int</span> *fd, <span class="keyword">const</span> <span class="keywordtype">char</span> *host, <span class="keywordtype">int</span> port );</div> <div class="line"><a name="l00063"></a><span class="lineno"> 63</span> </div> <div class="line"><a name="l00077"></a><span class="lineno"> 77</span> <span class="keywordtype">int</span> <a class="code" href="net_8h.html#a070a7665a1c2c3a5dc4d78aeef0f29de">net_bind</a>( <span class="keywordtype">int</span> *fd, <span class="keyword">const</span> <span class="keywordtype">char</span> *bind_ip, <span class="keywordtype">int</span> port );</div> <div class="line"><a name="l00078"></a><span class="lineno"> 78</span> </div> <div class="line"><a name="l00091"></a><span class="lineno"> 91</span> <span class="keywordtype">int</span> <a class="code" href="net_8h.html#aa7c66d2cf24804b92805eb6e598a9763">net_accept</a>( <span class="keywordtype">int</span> bind_fd, <span class="keywordtype">int</span> *client_fd, <span class="keywordtype">void</span> *client_ip );</div> <div class="line"><a name="l00092"></a><span class="lineno"> 92</span> </div> <div class="line"><a name="l00100"></a><span class="lineno"> 100</span> <span class="keywordtype">int</span> <a class="code" href="net_8h.html#a3b9985eaba07798c6f4d655fba05bb1b">net_set_block</a>( <span class="keywordtype">int</span> fd );</div> <div class="line"><a name="l00101"></a><span class="lineno"> 101</span> </div> <div class="line"><a name="l00109"></a><span class="lineno"> 109</span> <span class="keywordtype">int</span> <a class="code" href="net_8h.html#a8d15cfb98905e57d9f031a75d4c1dbbb">net_set_nonblock</a>( <span class="keywordtype">int</span> fd );</div> <div class="line"><a name="l00110"></a><span class="lineno"> 110</span> </div> <div class="line"><a name="l00119"></a><span class="lineno"> 119</span> <span class="keywordtype">void</span> <a class="code" href="net_8h.html#a2bcef97961f70e97e4cd9ec3ff16a6a6">net_usleep</a>( <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> usec );</div> <div class="line"><a name="l00120"></a><span class="lineno"> 120</span> </div> <div class="line"><a name="l00133"></a><span class="lineno"> 133</span> <span class="keywordtype">int</span> <a class="code" href="net_8h.html#aa76688ccbf03470a6cfc61c025758e9f">net_recv</a>( <span class="keywordtype">void</span> *ctx, <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> *buf, <span class="keywordtype">size_t</span> len );</div> <div class="line"><a name="l00134"></a><span class="lineno"> 134</span> </div> <div class="line"><a name="l00147"></a><span class="lineno"> 147</span> <span class="keywordtype">int</span> <a class="code" href="net_8h.html#ab14d74cc7497b93580c6a6ddb7c77561">net_send</a>( <span class="keywordtype">void</span> *ctx, <span class="keyword">const</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> *buf, <span class="keywordtype">size_t</span> len );</div> <div class="line"><a name="l00148"></a><span class="lineno"> 148</span> </div> <div class="line"><a name="l00154"></a><span class="lineno"> 154</span> <span class="keywordtype">void</span> <a class="code" href="net_8h.html#a1b0cf7ff43e2f8edb76e2f4724732cc6">net_close</a>( <span class="keywordtype">int</span> fd );</div> <div class="line"><a name="l00155"></a><span class="lineno"> 155</span> </div> <div class="line"><a name="l00156"></a><span class="lineno"> 156</span> <span class="preprocessor">#ifdef __cplusplus</span></div> <div class="line"><a name="l00157"></a><span class="lineno"> 157</span> <span class="preprocessor"></span>}</div> <div class="line"><a name="l00158"></a><span class="lineno"> 158</span> <span class="preprocessor">#endif</span></div> <div class="line"><a name="l00159"></a><span class="lineno"> 159</span> <span class="preprocessor"></span></div> <div class="line"><a name="l00160"></a><span class="lineno"> 160</span> <span class="preprocessor">#endif </span><span class="comment">/* net.h */</span><span class="preprocessor"></span></div> <div class="ttc" id="net_8h_html_a2bcef97961f70e97e4cd9ec3ff16a6a6"><div class="ttname"><a href="net_8h.html#a2bcef97961f70e97e4cd9ec3ff16a6a6">net_usleep</a></div><div class="ttdeci">void net_usleep(unsigned long usec)</div><div class="ttdoc">Portable usleep helper. </div></div> <div class="ttc" id="net_8h_html_a8d15cfb98905e57d9f031a75d4c1dbbb"><div class="ttname"><a href="net_8h.html#a8d15cfb98905e57d9f031a75d4c1dbbb">net_set_nonblock</a></div><div class="ttdeci">int net_set_nonblock(int fd)</div><div class="ttdoc">Set the socket non-blocking. </div></div> <div class="ttc" id="net_8h_html_ab14d74cc7497b93580c6a6ddb7c77561"><div class="ttname"><a href="net_8h.html#ab14d74cc7497b93580c6a6ddb7c77561">net_send</a></div><div class="ttdeci">int net_send(void *ctx, const unsigned char *buf, size_t len)</div><div class="ttdoc">Write at most &#39;len&#39; characters. </div></div> <div class="ttc" id="net_8h_html_a1b0cf7ff43e2f8edb76e2f4724732cc6"><div class="ttname"><a href="net_8h.html#a1b0cf7ff43e2f8edb76e2f4724732cc6">net_close</a></div><div class="ttdeci">void net_close(int fd)</div><div class="ttdoc">Gracefully shutdown the connection. </div></div> <div class="ttc" id="net_8h_html_a070a7665a1c2c3a5dc4d78aeef0f29de"><div class="ttname"><a href="net_8h.html#a070a7665a1c2c3a5dc4d78aeef0f29de">net_bind</a></div><div class="ttdeci">int net_bind(int *fd, const char *bind_ip, int port)</div><div class="ttdoc">Create a listening socket on bind_ip:port. </div></div> <div class="ttc" id="net_8h_html_aa7c66d2cf24804b92805eb6e598a9763"><div class="ttname"><a href="net_8h.html#aa7c66d2cf24804b92805eb6e598a9763">net_accept</a></div><div class="ttdeci">int net_accept(int bind_fd, int *client_fd, void *client_ip)</div><div class="ttdoc">Accept a connection from a remote client. </div></div> <div class="ttc" id="net_8h_html_a49c549b21517d6f905eb9845224f2773"><div class="ttname"><a href="net_8h.html#a49c549b21517d6f905eb9845224f2773">net_connect</a></div><div class="ttdeci">int net_connect(int *fd, const char *host, int port)</div><div class="ttdoc">Initiate a TCP connection with host:port. </div></div> <div class="ttc" id="net_8h_html_a3b9985eaba07798c6f4d655fba05bb1b"><div class="ttname"><a href="net_8h.html#a3b9985eaba07798c6f4d655fba05bb1b">net_set_block</a></div><div class="ttdeci">int net_set_block(int fd)</div><div class="ttdoc">Set the socket blocking. </div></div> <div class="ttc" id="net_8h_html_aa76688ccbf03470a6cfc61c025758e9f"><div class="ttname"><a href="net_8h.html#aa76688ccbf03470a6cfc61c025758e9f">net_recv</a></div><div class="ttdeci">int net_recv(void *ctx, unsigned char *buf, size_t len)</div><div class="ttdoc">Read at most &#39;len&#39; characters. </div></div> </div><!-- fragment --></div><!-- contents --> <!-- start footer part --> <hr class="footer"/><address class="footer"><small> Generated on Thu Jul 31 2014 11:35:51 for PolarSSL v1.3.8 by  <a href="http://www.doxygen.org/index.html"> <img class="footer" src="doxygen.png" alt="doxygen"/> </a> 1.8.5 </small></address> </body> </html>