⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 group__tcp__app__api.html

📁 Freescale mcu OpenTCP-1.0.4.doc.html.zip 文档
💻 HTML
📖 第 1 页 / 共 3 页
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"><title>TCP API functions</title><link href="doxygen.css" rel="stylesheet" type="text/css"></head><body><!-- Generated by Doxygen 1.2.18 --><center><a class="qindex" href="main.html">Main Page</a> &nbsp; <a class="qindex" href="modules.html">Modules</a> &nbsp; <a class="qindex" href="annotated.html">Data Structures</a> &nbsp; <a class="qindex" href="files.html">File List</a> &nbsp; <a class="qindex" href="functions.html">Data Fields</a> &nbsp; <a class="qindex" href="globals.html">Globals</a> &nbsp; <a class="qindex" href="pages.html">Related Pages</a> &nbsp; <a class="qindex" href="examples.html">Examples</a> &nbsp; </center><hr><h1>TCP API functions</h1><hr><a name="_details"></a><h2>Detailed Description</h2>These are the functions that applications need to use in  order to communicate using TCP as well as to work with TCP  sockets so as to achieve such a communication. <table border=0 cellpadding=0 cellspacing=0><tr><td></td></tr><tr><td colspan=2><br><h2>Functions</h2></td></tr><tr><td nowrap align=right valign=top>INT8&nbsp;</td><td valign=bottom><a class="el" href="group__tcp__app__api.html#a0">tcp_getsocket</a> (UINT8, UINT8, UINT16, INT32(*)(INT8, UINT8, UINT32, UINT32))</td></tr><tr><td>&nbsp;</td><td><font size=-1><em>Allocate a free socket in TCP socket pool.</em> <a href="#a0"></a><em></em></font><br><br></td></tr><tr><td nowrap align=right valign=top>INT8&nbsp;</td><td valign=bottom><a class="el" href="group__tcp__app__api.html#a1">tcp_releasesocket</a> (INT8)</td></tr><tr><td>&nbsp;</td><td><font size=-1><em>Release a TCP socket.</em> <a href="#a1"></a><em></em></font><br><br></td></tr><tr><td nowrap align=right valign=top>INT8&nbsp;</td><td valign=bottom><a class="el" href="group__tcp__app__api.html#a2">tcp_listen</a> (INT8, UINT16)</td></tr><tr><td>&nbsp;</td><td><font size=-1><em>Put TCP socket to listen on a given port.</em> <a href="#a2"></a><em></em></font><br><br></td></tr><tr><td nowrap align=right valign=top>INT8&nbsp;</td><td valign=bottom><a class="el" href="group__tcp__app__api.html#a3">tcp_connect</a> (INT8, UINT32, UINT16, UINT16)</td></tr><tr><td>&nbsp;</td><td><font size=-1><em>Initialize connection establishment towards remote IP&amp;port.</em> <a href="#a3"></a><em></em></font><br><br></td></tr><tr><td nowrap align=right valign=top>INT16&nbsp;</td><td valign=bottom><a class="el" href="group__tcp__app__api.html#a4">tcp_send</a> (INT8, UINT8 *, UINT16, UINT16)</td></tr><tr><td>&nbsp;</td><td><font size=-1><em>Send user data over TCP using given TCP socket.</em> <a href="#a4"></a><em></em></font><br><br></td></tr><tr><td nowrap align=right valign=top>INT8&nbsp;</td><td valign=bottom><a class="el" href="group__tcp__app__api.html#a5">tcp_close</a> (INT8)</td></tr><tr><td>&nbsp;</td><td><font size=-1><em>Initiate TCP connection closing procedure.</em> <a href="#a5"></a><em></em></font><br><br></td></tr><tr><td nowrap align=right valign=top>INT8&nbsp;</td><td valign=bottom><a class="el" href="group__tcp__app__api.html#a6">tcp_getstate</a> (INT8)</td></tr><tr><td>&nbsp;</td><td><font size=-1><em>Get current state of the socket.</em> <a href="#a6"></a><em></em></font><br><br></td></tr><tr><td nowrap align=right valign=top>INT16&nbsp;</td><td valign=bottom><a class="el" href="group__tcp__app__api.html#a7">tcp_checksend</a> (INT8)</td></tr><tr><td>&nbsp;</td><td><font size=-1><em>Checks if it's possible to send data using given socket.</em> <a href="#a7"></a><em></em></font><br><br></td></tr><tr><td nowrap align=right valign=top>INT8&nbsp;</td><td valign=bottom><a class="el" href="group__tcp__app__api.html#a8">tcp_abort</a> (INT8)</td></tr><tr><td>&nbsp;</td><td><font size=-1><em>Reset connection and place socket to closed state.</em> <a href="#a8"></a><em></em></font><br><br></td></tr></table><hr><h2>Function Documentation</h2><a name="a0" doxytag="tcp_ip.h::tcp_getsocket"></a><p><table width="100%" cellpadding="2" cellspacing="0" border="0">  <tr>    <td class="md">      <table cellpadding="0" cellspacing="0" border="0">        <tr>          <td class="md" nowrap valign="top"> INT8 tcp_getsocket </td>          <td class="md" valign="top">(&nbsp;</td>          <td class="md" nowrap valign="top">UINT8&nbsp;</td>          <td class="mdname" nowrap>&nbsp; <em>soctype</em>, </td>        </tr>        <tr>          <td></td>          <td></td>          <td class="md" nowrap>UINT8&nbsp;</td>          <td class="mdname" nowrap>&nbsp; <em>tos</em>, </td>        </tr>        <tr>          <td></td>          <td></td>          <td class="md" nowrap>UINT16&nbsp;</td>          <td class="mdname" nowrap>&nbsp; <em>tout</em>, </td>        </tr>        <tr>          <td></td>          <td></td>          <td class="md" nowrap>INT32(*&nbsp;</td>          <td class="mdname" nowrap>&nbsp; <em>listener</em>)(INT8, UINT8, UINT32, UINT32)</td>        </tr>        <tr>          <td></td>          <td class="md">)&nbsp;</td>          <td class="md" colspan="2"></td>        </tr>      </table>    </td>  </tr></table><table cellspacing=5 cellpadding=0 border=0>  <tr>    <td>      &nbsp;    </td>    <td><p><dl compact><dt><b>Author: </b></dt><dd> <ul><li> Jari Lahti (<a href="mailto:jari.lahti@violasystems.com">jari.lahti@violasystems.com</a>) </ul></dl><dl compact><dt><b>Date: </b></dt><dd>21.07.2002 </dl><dl compact><dt><b>Parameters: </b></dt><dd><table border=0 cellspacing=2 cellpadding=0><tr><td valign=top><em>soctype</em>&nbsp;</td><td>type of socket wanted. Can take one of the following values: <ul><li> <a class="el" href="tcp__ip_8h.html#a38">TCP_TYPE_NONE</a> <li> <a class="el" href="tcp__ip_8h.html#a39">TCP_TYPE_SERVER</a> <li> <a class="el" href="tcp__ip_8h.html#a40">TCP_TYPE_CLIENT</a> <li> <a class="el" href="tcp__ip_8h.html#a41">TCP_TYPE_CLIENT_SERVER</a> </ul></td></tr><tr><td valign=top><em>tos</em>&nbsp;</td><td>type of service for socket. For now only <a class="el" href="tcp__ip_8h.html#a18">TCP_TOS_NORMAL</a>. </td></tr><tr><td valign=top><em>tout</em>&nbsp;</td><td>Timeout of socket in seconds. Defines after how many seconds of inactivity (application not sending and/or receiving any data over TCP connection) will the TCP socket automatically be closed. </td></tr><tr><td valign=top><em>listener</em>&nbsp;</td><td>pointer to callback function that will be invoked by the TCP/IP stack to inform socket application of certain events. See <a class="el" href="tcp__client__demo_8c.html#a7">tcpc_demo_eventlistener()</a> and <a class="el" href="tcp__server__demo_8c.html#a5">tcps_demo_eventlistener()</a> for more information on events and possible actions. </td></tr></table></dl><dl compact><dt><b>Returns: </b></dt><dd> <ul><li> -1 - Error getting requested socket <li> &gt;=0 - Handle to reserved socket</ul></dl>Invoke this function to try to obtain a free socket from TCP socket pool. Function returns a handle to the free socket that is later used for  accessing the allocated socket (opening, connecting, sending data, closing, aborting, etc.). <dl compact><dt><b>Examples: </b></dt><dd><a class="el" href="tcp__client__demo_8c-example.html#a0">tcp_client_demo.c</a>, and <a class="el" href="tcp__server__demo_8c-example.html#a0">tcp_server_demo.c</a>.</dl><p>Definition at line <a class="el" href="tcp_8c-source.html#l00155">155</a> of file <a class="el" href="tcp_8c-source.html">tcp.c</a>.<p>References <a class="el" href="structtcb.html#m16">tcb::event_listener</a>, <a class="el" href="tcp__ip_8h-source.html#l00622">tcb::flags</a>, <a class="el" href="tcp__ip_8h-source.html#l00625">tcb::locport</a>, <a class="el" href="tcp__ip_8h-source.html#l00623">tcb::rem_ip</a>, <a class="el" href="tcp__ip_8h-source.html#l00624">tcb::remport</a>, <a class="el" href="tcp__ip_8h-source.html#l00609">tcb::state</a>, <a class="el" href="tcp__ip_8h-source.html#l00333">TCP_STATE_FREE</a>, <a class="el" href="tcp__ip_8h-source.html#l00334">TCP_STATE_RESERVED</a>, <a class="el" href="tcp__ip_8h-source.html#l00320">TCP_TYPE_CLIENT</a>, <a class="el" href="tcp__ip_8h-source.html#l00329">TCP_TYPE_CLIENT_SERVER</a>, <a class="el" href="tcp__ip_8h-source.html#l00300">TCP_TYPE_NONE</a>, <a class="el" href="tcp__ip_8h-source.html#l00310">TCP_TYPE_SERVER</a>, <a class="el" href="timers_8h-source.html#l00086">TIMERTIC</a>, <a class="el" href="tcp__ip_8h-source.html#l00631">tcb::tos</a>, <a class="el" href="tcp__ip_8h-source.html#l00630">tcb::tout</a>, and <a class="el" href="tcp__ip_8h-source.html#l00621">tcb::type</a>.<p>Referenced by <a class="el" href="http__server_8c-source.html#l00093">https_init()</a>, <a class="el" href="pop3__client_8c-source.html#l00148">pop3c_init()</a>, and <a class="el" href="smtp__client_8c-source.html#l00155">smtpc_init()</a>.    </td>  </tr></table><a name="a1" doxytag="tcp_ip.h::tcp_releasesocket"></a><p><table width="100%" cellpadding="2" cellspacing="0" border="0">  <tr>    <td class="md">      <table cellpadding="0" cellspacing="0" border="0">        <tr>          <td class="md" nowrap valign="top"> INT8 tcp_releasesocket </td>          <td class="md" valign="top">(&nbsp;</td>          <td class="md" nowrap valign="top">INT8&nbsp;</td>          <td class="mdname1" valign="top" nowrap>&nbsp; <em>sochandle</em>          </td>          <td class="md" valign="top">)&nbsp;</td>          <td class="md" nowrap></td>        </tr>      </table>    </td>  </tr></table><table cellspacing=5 cellpadding=0 border=0>  <tr>    <td>      &nbsp;    </td>    <td><p><dl compact><dt><b>Author: </b></dt><dd> <ul><li> Jari Lahti (<a href="mailto:jari.lahti@violasystems.com">jari.lahti@violasystems.com</a>) </ul></dl><dl compact><dt><b>Date: </b></dt><dd>21.07.2002 </dl><dl compact><dt><b>Parameters: </b></dt><dd><table border=0 cellspacing=2 cellpadding=0><tr><td valign=top><em>sochandle</em>&nbsp;</td><td>handle to socket to be released </td></tr></table></dl><dl compact><dt><b>Returns: </b></dt><dd> <ul><li> -1 - Error releasing the socket (Wrong socket handle or socket not in proper state to be released) <li> &gt;=0 - handle of the released socket (can not be used any more untill allocated again with <a class="el" href="group__tcp__app__api.html#a0">tcp_getsocket()</a>).</ul></dl>Once the application does not need the TCP socket any more it can invoke this function in order to release it. This is usefull if there is a very limited number of sockets (in order to save some memory) shared among several applications. <p>Definition at line <a class="el" href="tcp_8c-source.html#l00228">228</a> of file <a class="el" href="tcp_8c-source.html">tcp.c</a>.<p>References <a class="el" href="structtcb.html#m16">tcb::event_listener</a>, <a class="el" href="tcp__ip_8h-source.html#l00622">tcb::flags</a>, <a class="el" href="tcp__ip_8h-source.html#l00625">tcb::locport</a>, <a class="el" href="tcp__ip_8h-source.html#l00623">tcb::rem_ip</a>, <a class="el" href="tcp__ip_8h-source.html#l00624">tcb::remport</a>, <a class="el" href="tcp__ip_8h-source.html#l00609">tcb::state</a>, <a class="el" href="tcp__ip_8h-source.html#l00335">TCP_STATE_CLOSED</a>, <a class="el" href="tcp__ip_8h-source.html#l00333">TCP_STATE_FREE</a>, <a class="el" href="tcp__ip_8h-source.html#l00334">TCP_STATE_RESERVED</a>, <a class="el" href="tcp__ip_8h-source.html#l00300">TCP_TYPE_NONE</a>, <a class="el" href="tcp__ip_8h-source.html#l00631">tcb::tos</a>, and <a class="el" href="tcp__ip_8h-source.html#l00621">tcb::type</a>.    </td>  </tr></table><a name="a2" doxytag="tcp_ip.h::tcp_listen"></a><p><table width="100%" cellpadding="2" cellspacing="0" border="0">  <tr>    <td class="md">      <table cellpadding="0" cellspacing="0" border="0">        <tr>          <td class="md" nowrap valign="top"> INT8 tcp_listen </td>          <td class="md" valign="top">(&nbsp;</td>          <td class="md" nowrap valign="top">INT8&nbsp;</td>          <td class="mdname" nowrap>&nbsp; <em>sochandle</em>, </td>        </tr>        <tr>          <td></td>          <td></td>          <td class="md" nowrap>UINT16&nbsp;</td>          <td class="mdname" nowrap>&nbsp; <em>port</em></td>        </tr>        <tr>          <td></td>          <td class="md">)&nbsp;</td>          <td class="md" colspan="2"></td>        </tr>      </table>    </td>  </tr></table><table cellspacing=5 cellpadding=0 border=0>  <tr>    <td>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -