📄 a00147.html
字号:
<td class="md" nowrap valign="top"><a class="el" href="a00150.html#g1ef35301f43a5bbb9f89f07b5a36b9a0">uip_ipaddr_t</a> * </td> <td class="mdname" nowrap> <em>ripaddr</em>, </td> </tr> <tr> <td class="md" nowrap align="right"></td> <td class="md"></td> <td class="md" nowrap><a class="el" href="a00153.html#g77570ac4fcab86864fa1916e55676da2">u16_t</a> </td> <td class="mdname" nowrap> <em>port</em></td> </tr> <tr> <td class="md"></td> <td class="md">) </td> <td class="md" colspan="2"></td> </tr> </table> </td> </tr></table><table cellspacing="5" cellpadding="0" border="0"> <tr> <td> </td> <td><p>Connect to a remote host using TCP. <p>This function is used to start a new connection to the specified port on the specied host. It allocates a new connection identifier, sets the connection to the SYN_SENT state and sets the retransmission timer to 0. This will cause a TCP SYN segment to be sent out the next time this connection is periodically processed, which usually is done within 0.5 seconds after the call to <a class="el" href="a00147.html#g8096b0c4b543dc408f4dd031ddae7240">uip_connect()</a>.<p><dl compact><dt><b>Note:</b></dt><dd>This function is avaliable only if support for active open has been configured by defining UIP_ACTIVE_OPEN to 1 in <a class="el" href="a00140.html">uipopt.h</a>.<p>Since this function requires the port number to be in network byte order, a conversion using <a class="el" href="a00148.html#g69a7a4951ff21b302267532c21ee78fc">HTONS()</a> or <a class="el" href="a00148.html#ga22b04cac8cf283ca12f028578bebc06">htons()</a> is necessary.</dd></dl><div class="fragment"><pre class="fragment"> <a class="code" href="a00150.html#g1ef35301f43a5bbb9f89f07b5a36b9a0">uip_ipaddr_t</a> ipaddr; <a class="code" href="a00148.html#g87f0b54ade0d159fba495089128a4932">uip_ipaddr</a>(&ipaddr, 192,168,1,2); <a class="code" href="a00147.html#g8096b0c4b543dc408f4dd031ddae7240">uip_connect</a>(&ipaddr, <a class="code" href="a00148.html#g69a7a4951ff21b302267532c21ee78fc">HTONS</a>(80));</pre></div><p><dl compact><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td valign="top"></td><td valign="top"><em>ripaddr</em> </td><td>The IP address of the remote hot.</td></tr> <tr><td valign="top"></td><td valign="top"><em>port</em> </td><td>A 16-bit port number in network byte order.</td></tr> </table></dl><dl compact><dt><b>Returns:</b></dt><dd>A pointer to the uIP connection identifier for the new connection, or NULL if no connection could be allocated. </dd></dl><dl compact><dt><b>Examples: </b></dt><dd><a class="el" href="a00038.html#a190">smtp.c</a>, and <a class="el" href="a00040.html#a273">webclient.c</a>.</dl><p>Definition at line <a class="el" href="a00201.html#l00407">407</a> of file <a class="el" href="a00201.html">uip.c</a>.<p>References <a class="el" href="a00201.html#l01882">htons()</a>, <a class="el" href="a00202.html#l01156">uip_conn::lport</a>, <a class="el" href="a00202.html#l01174">uip_conn::tcpstateflags</a>, <a class="el" href="a00202.html#l01372">UIP_CLOSED</a>, <a class="el" href="a00201.html#l00163">uip_conn</a>, <a class="el" href="a00206.html#l00245">UIP_CONNS</a>, and <a class="el" href="a00201.html#l00166">uip_conns</a>.<p>Referenced by <a class="el" href="a00174.html#l00233">smtp_send()</a>, and <a class="el" href="a00180.html#l00140">webclient_get()</a>. </td> </tr></table><a class="anchor" name="gdd1ab3704ecd4900eec61a6897d32dc8"></a><!-- doxytag: member="uip.h::uip_listen" ref="gdd1ab3704ecd4900eec61a6897d32dc8" args="(u16_t port)" --><p><table class="mdTable" cellpadding="2" cellspacing="0"> <tr> <td class="mdRow"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top">void uip_listen </td> <td class="md" valign="top">( </td> <td class="md" nowrap valign="top"><a class="el" href="a00153.html#g77570ac4fcab86864fa1916e55676da2">u16_t</a> </td> <td class="mdname1" valign="top" nowrap> <em>port</em> </td> <td class="md" valign="top"> ) </td> <td class="md" nowrap></td> </tr> </table> </td> </tr></table><table cellspacing="5" cellpadding="0" border="0"> <tr> <td> </td> <td><p>Start listening to the specified port. <p><dl compact><dt><b>Note:</b></dt><dd>Since this function expects the port number in network byte order, a conversion using <a class="el" href="a00148.html#g69a7a4951ff21b302267532c21ee78fc">HTONS()</a> or <a class="el" href="a00148.html#ga22b04cac8cf283ca12f028578bebc06">htons()</a> is necessary.</dd></dl><div class="fragment"><pre class="fragment"> <a class="code" href="a00147.html#gdd1ab3704ecd4900eec61a6897d32dc8">uip_listen</a>(<a class="code" href="a00148.html#g69a7a4951ff21b302267532c21ee78fc">HTONS</a>(80));</pre></div><p><dl compact><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td valign="top"></td><td valign="top"><em>port</em> </td><td>A 16-bit port number in network byte order. </td></tr> </table></dl><dl compact><dt><b>Examples: </b></dt><dd><a class="el" href="a00036.html#a102">hello-world.c</a>, and <a class="el" href="a00044.html#a218">telnetd.c</a>.</dl><p>Definition at line <a class="el" href="a00201.html#l00529">529</a> of file <a class="el" href="a00201.html">uip.c</a>.<p>References <a class="el" href="a00206.html#l00259">UIP_LISTENPORTS</a>.<p>Referenced by <a class="el" href="a00170.html#l00041">hello_world_init()</a>, and <a class="el" href="a00184.html#l00333">httpd_init()</a>. </td> </tr></table><a class="anchor" name="g04b053a623aac7cd4195157d470661b3"></a><!-- doxytag: member="uip.h::uip_send" ref="g04b053a623aac7cd4195157d470661b3" args="(const void *data, int len)" --><p><table class="mdTable" cellpadding="2" cellspacing="0"> <tr> <td class="mdRow"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top">void uip_send </td> <td class="md" valign="top">( </td> <td class="md" nowrap valign="top">const void * </td> <td class="mdname" nowrap> <em>data</em>, </td> </tr> <tr> <td class="md" nowrap align="right"></td> <td class="md"></td> <td class="md" nowrap>int </td> <td class="mdname" nowrap> <em>len</em></td> </tr> <tr> <td class="md"></td> <td class="md">) </td> <td class="md" colspan="2"></td> </tr> </table> </td> </tr></table><table cellspacing="5" cellpadding="0" border="0"> <tr> <td> </td> <td><p>Send data on the current connection. <p>This function is used to send out a single segment of TCP data. Only applications that have been invoked by uIP for event processing can send data.<p>The amount of data that actually is sent out after a call to this funcion is determined by the maximum amount of data TCP allows. uIP will automatically crop the data so that only the appropriate amount of data is sent. The function <a class="el" href="a00147.html#gb5fecbc62edd128012cea0f47b57ab9f">uip_mss()</a> can be used to query uIP for the amount of data that actually will be sent.<p><dl compact><dt><b>Note:</b></dt><dd>This function does not guarantee that the sent data will arrive at the destination. If the data is lost in the network, the application will be invoked with the <a class="el" href="a00147.html#ga8933ad15a2e2947dae4a5cff50e6007">uip_rexmit()</a> event being set. The application will then have to resend the data using this function.</dd></dl><dl compact><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td valign="top"></td><td valign="top"><em>data</em> </td><td>A pointer to the data which is to be sent.</td></tr> <tr><td valign="top"></td><td valign="top"><em>len</em> </td><td>The maximum amount of data bytes to be sent. </td></tr> </table></dl><dl compact><dt><b>Examples: </b></dt><dd><a class="el" href="a00048.html#a10">dhcpc.c</a>, <a class="el" href="a00044.html#a226">telnetd.c</a>, and <a class="el" href="a00040.html#a278">webclient.c</a>.</dl><p>Definition at line <a class="el" href="a00201.html#l01888">1888</a> of file <a class="el" href="a00201.html">uip.c</a>.<p>References <a class="el" href="a00201.html#l00145">uip_sappdata</a>, and <a class="el" href="a00201.html#l00155">uip_slen</a>. </td> </tr></table><a class="anchor" name="g79c4110211247df3fb30b8cf1c4c02af"></a><!-- doxytag: member="uip.h::uip_udp_new" ref="g79c4110211247df3fb30b8cf1c4c02af" args="(uip_ipaddr_t *ripaddr, u16_t rport)" --><p><table class="mdTable" cellpadding="2" cellspacing="0"> <tr> <td class="mdRow"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top">struct <a class="el" href="a00095.html">uip_udp_conn</a>* uip_udp_new </td> <td class="md" valign="top">( </td> <td class="md" nowrap valign="top"><a class="el" href="a00150.html#g1ef35301f43a5bbb9f89f07b5a36b9a0">uip_ipaddr_t</a> * </td> <td class="mdname" nowrap> <em>ripaddr</em>, </td> </tr> <tr> <td class="md" nowrap align="right"></td> <td class="md"></td> <td class="md" nowrap><a class="el" href="a00153.html#g77570ac4fcab86864fa1916e55676da2">u16_t</a> </td> <td class="mdname" nowrap> <em>rport</em></td> </tr> <tr> <td class="md"></td> <td class="md">) </td> <td class="md" colspan="2"></td> </tr> </table> </td> </tr></table><table cellspacing="5" cellpadding="0" border="0"> <tr> <td> </td> <td><p>Set up a new UDP connection. <p>This function sets up a new UDP connection. The function will automatically allocate an unused local port for the new connection. However, another port can be chosen by using the <a class="el" href="a00147.html#ga20812098a4663c8a9fc4ce8e95391b6">uip_udp_bind()</a> call, after the <a class="el" href="a00147.html#g79c4110211247df3fb30b8cf1c4c02af">uip_udp_new()</a> function has been called.<p>Example: <div class="fragment"><pre class="fragment"> <a class="code" href="a00150.html#g1ef35301f43a5bbb9f89f07b5a36b9a0">uip_ipaddr_t</a> addr; <span class="keyword">struct </span><a class="code" href="a00095.html">uip_udp_conn</a> *c; <a class="code" href="a00148.html#g87f0b54ade0d159fba495089128a4932">uip_ipaddr</a>(&addr, 192,168,2,1); c = <a class="code" href="a00147.html#g79c4110211247df3fb30b8cf1c4c02af">uip_udp_new</a>(&addr, <a class="code" href="a00148.html#g69a7a4951ff21b302267532c21ee78fc">HTONS</a>(12345)); <span class="keywordflow">if</span>(c != <a class="code" href="a00160.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>) { <a class="code" href="a00147.html#ga20812098a4663c8a9fc4ce8e95391b6">uip_udp_bind</a>(c, <a class="code" href="a00148.html#g69a7a4951ff21b302267532c21ee78fc">HTONS</a>(12344)); }</pre></div> <dl compact><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td valign="top"></td><td valign="top"><em>ripaddr</em> </td><td>The IP address of the remote host.</td></tr> <tr><td valign="top"></td><td valign="top"><em>rport</em> </td><td>The remote port number in network byte order.</td></tr> </table></dl><dl compact><dt><b>Returns:</b></dt><dd>The <a class="el" href="a00095.html">uip_udp_conn</a> structure for the new connection or NULL if no connection could be allocated. </dd></dl><dl compact><dt><b>Examples: </b></dt><dd><a class="el" href="a00048.html#a38">dhcpc.c</a>, and <a class="el" href="a00046.html#a153">resolv.c</a>.</dl><p>Definition at line <a class="el" href="a00201.html#l00473">473</a> of file <a class="el" href="a00201.html">uip.c</a>.<p>References <a class="el" href="a00201.html#l01882">htons()</a>, <a class="el" href="a00202.html#l01212">uip_udp_conn::lport</a>, <a class="el" href="a00201.html#l00173">uip_udp_conn</a>, <a class="el" href="a00206.html#l00206">UIP_UDP_CONNS</a>, and <a class="el" href="a00201.html#l00174">uip_udp_conns</a>.<p>Referenced by <a class="el" href="a00172.html#l00438">resolv_conf()</a>. </td> </tr></table><a class="anchor" name="gaa585784b0914cac1d37f07f85457008"></a><!-- doxytag: member="uip.h::uip_unlisten" ref="gaa585784b0914cac1d37f07f85457008" args="(u16_t port)" --><p><table class="mdTable" cellpadding="2" cellspacing="0"> <tr> <td class="mdRow"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top">void uip_unlisten </td> <td class="md" valign="top">( </td> <td class="md" nowrap valign="top"><a class="el" href="a00153.html#g77570ac4fcab86864fa1916e55676da2">u16_t</a> </td> <td class="mdname1" valign="top" nowrap> <em>port</em> </td> <td class="md" valign="top"> ) </td> <td class="md" nowrap></td> </tr> </table> </td> </tr></table><table cellspacing="5" cellpadding="0" border="0"> <tr> <td> </td> <td><p>Stop listening to the specified port. <p><dl compact><dt><b>Note:</b></dt><dd>Since this function expects the port number in network byte order, a conversion using <a class="el" href="a00148.html#g69a7a4951ff21b302267532c21ee78fc">HTONS()</a> or <a class="el" href="a00148.html#ga22b04cac8cf283ca12f028578bebc06">htons()</a> is necessary.</dd></dl><div class="fragment"><pre class="fragment"> <a class="code" href="a00147.html#gaa585784b0914cac1d37f07f85457008">uip_unlisten</a>(<a class="code" href="a00148.html#g69a7a4951ff21b302267532c21ee78fc">HTONS</a>(80));</pre></div><p><dl compact><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td valign="top"></td><td valign="top"><em>port</em> </td><td>A 16-bit port number in network byte order. </td></tr> </table></dl><p>Definition at line <a class="el" href="a00201.html#l00518">518</a> of file <a class="el" href="a00201.html">uip.c</a>.<p>References <a class="el" href="a00206.html#l00259">UIP_LISTENPORTS</a>. </td> </tr></table><hr size="1"><address style="align: right;"><small>Generated on Mon Jun 12 10:23:02 2006 for uIP 1.0 by <a href="http://www.doxygen.org/index.html"><img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.4.6 </small></address></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -