rtt-f030/components/net/uip/doc/html/a00158.html

694 lines
37 KiB
HTML
Raw Normal View History

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>uIP 1.0: Protosockets library</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.4.6 -->
<div class="tabs">
<ul>
<li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="modules.html"><span>Modules</span></a></li>
<li><a href="classes.html"><span>Data&nbsp;Structures</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
<li><a href="examples.html"><span>Examples</span></a></li>
</ul></div>
<h1>Protosockets library</h1><hr><a name="_details"></a><h2>Detailed Description</h2>
The protosocket library provides an interface to the uIP stack that is similar to the traditional BSD socket interface.
<p>
Unlike programs written for the ordinary uIP event-driven interface, programs written with the protosocket library are executed in a sequential fashion and does not have to be implemented as explicit state machines.<p>
Protosockets only work with TCP connections.<p>
The protosocket library uses <a class="el" href="a00142.html">Protothreads</a> protothreads to provide sequential control flow. This makes the protosockets lightweight in terms of memory, but also means that protosockets inherits the functional limitations of protothreads. Each protosocket lives only within a single function. Automatic variables (stack variables) are not retained across a protosocket library function call.<p>
<dl compact><dt><b>Note:</b></dt><dd>Because the protosocket library uses protothreads, local variables will not always be saved across a call to a protosocket library function. It is therefore advised that local variables are used with extreme care.</dd></dl>
The protosocket library provides functions for sending data without having to deal with retransmissions and acknowledgements, as well as functions for reading data without having to deal with data being split across more than one TCP segment.<p>
Because each protosocket runs as a protothread, the protosocket has to be started with a call to <a class="el" href="a00158.html#g84901a5aa60040e96d272a69977edd22">PSOCK_BEGIN()</a> at the start of the function in which the protosocket is used. Similarly, the protosocket protothread can be terminated by a call to <a class="el" href="a00158.html#gfa11b2a1faf395ae2a6626e01c482d5d">PSOCK_EXIT()</a>.
<p>
<table border="0" cellpadding="0" cellspacing="0">
<tr><td></td></tr>
<tr><td colspan="2"><br><h2>Files</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">file &nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00127.html">psock.h</a></td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Protosocket library header file. <br></td></tr>
<p>
<tr><td colspan="2"><br><h2>Data Structures</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">struct &nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00083.html">psock_buf</a></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">struct &nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00082.html">psock</a></td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">The representation of a protosocket. <a href="a00082.html#_details">More...</a><br></td></tr>
<tr><td colspan="2"><br><h2>Defines</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00158.html#g26ae707402e494f3895a9f012a93ea29">PSOCK_INIT</a>(<a class="el" href="a00082.html">psock</a>, buffer, buffersize)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Initialize a protosocket. <a href="#g26ae707402e494f3895a9f012a93ea29"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00158.html#g84901a5aa60040e96d272a69977edd22">PSOCK_BEGIN</a>(<a class="el" href="a00082.html">psock</a>)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Start the protosocket protothread in a function. <a href="#g84901a5aa60040e96d272a69977edd22"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00158.html#g70d236d1cf34b4e21836edda60247b70">PSOCK_SEND</a>(<a class="el" href="a00082.html">psock</a>, data, datalen)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Send data. <a href="#g70d236d1cf34b4e21836edda60247b70"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00158.html#gb0ad55aa96dd1d200cd0fc5a99f6a4f7">PSOCK_SEND_STR</a>(<a class="el" href="a00082.html">psock</a>, str)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Send a null-terminated string. <a href="#gb0ad55aa96dd1d200cd0fc5a99f6a4f7"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00158.html#g10d9a9201cba1a6db623284c475c6cea">PSOCK_GENERATOR_SEND</a>(<a class="el" href="a00082.html">psock</a>, generator, arg)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Generate data with a function and send it. <a href="#g10d9a9201cba1a6db623284c475c6cea"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00158.html#g5d56800f82bfc7bbf53bb4a659589812">PSOCK_CLOSE</a>(<a class="el" href="a00082.html">psock</a>)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Close a protosocket. <a href="#g5d56800f82bfc7bbf53bb4a659589812"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00158.html#gd895ab98c54d9966ff554aa873151751">PSOCK_READBUF</a>(<a class="el" href="a00082.html">psock</a>)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Read data until the buffer is full. <a href="#gd895ab98c54d9966ff554aa873151751"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00158.html#gb5d9c0becf7cb32d0aaef466839dd92e">PSOCK_READTO</a>(<a class="el" href="a00082.html">psock</a>, c)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Read data up to a specified character. <a href="#gb5d9c0becf7cb32d0aaef466839dd92e"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00158.html#g4ab2de595d36e9e55dd61f6ecd139162">PSOCK_DATALEN</a>(<a class="el" href="a00082.html">psock</a>)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">The length of the data that was previously read. <a href="#g4ab2de595d36e9e55dd61f6ecd139162"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00158.html#gfa11b2a1faf395ae2a6626e01c482d5d">PSOCK_EXIT</a>(<a class="el" href="a00082.html">psock</a>)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Exit the protosocket's protothread. <a href="#gfa11b2a1faf395ae2a6626e01c482d5d"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00158.html#gc7cc1dba1819f7fcdaa9ff9eed5a08f4">PSOCK_CLOSE_EXIT</a>(<a class="el" href="a00082.html">psock</a>)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Close a protosocket and exit the protosocket's protothread. <a href="#gc7cc1dba1819f7fcdaa9ff9eed5a08f4"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00158.html#g4a264bb64ae706d53f572b1d9e4037a2">PSOCK_END</a>(<a class="el" href="a00082.html">psock</a>)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Declare the end of a protosocket's protothread. <a href="#g4a264bb64ae706d53f572b1d9e4037a2"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00158.html#g55ce98ea4d6f22e9d5068b904d4d2447">PSOCK_NEWDATA</a>(<a class="el" href="a00082.html">psock</a>)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Check if new data has arrived on a protosocket. <a href="#g55ce98ea4d6f22e9d5068b904d4d2447"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00158.html#g2ebfe5c8a7f3173714efdf2df74fc392">PSOCK_WAIT_UNTIL</a>(<a class="el" href="a00082.html">psock</a>, condition)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Wait until a condition is true. <a href="#g2ebfe5c8a7f3173714efdf2df74fc392"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="ga87ff36af81990e6ffe20d76d5e4606f"></a><!-- doxytag: member="psock::PSOCK_WAIT_THREAD" ref="ga87ff36af81990e6ffe20d76d5e4606f" args="(psock, condition)" -->
#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00158.html#ga87ff36af81990e6ffe20d76d5e4606f">PSOCK_WAIT_THREAD</a>(<a class="el" href="a00082.html">psock</a>, condition)&nbsp;&nbsp;&nbsp;PT_WAIT_THREAD(&amp;((<a class="el" href="a00082.html">psock</a>)-&gt;<a class="el" href="a00084.html">pt</a>), (condition))</td></tr>
<tr><td colspan="2"><br><h2>Functions</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="g3178402dd725776415bf9745e7bf92ba"></a><!-- doxytag: member="psock::psock_datalen" ref="g3178402dd725776415bf9745e7bf92ba" args="(struct psock *psock)" -->
<a class="el" href="a00153.html#g77570ac4fcab86864fa1916e55676da2">u16_t</a>&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00158.html#g3178402dd725776415bf9745e7bf92ba">psock_datalen</a> (struct <a class="el" href="a00082.html">psock</a> *<a class="el" href="a00082.html">psock</a>)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="g3b19f65e48079d8105be2a99b5b4b2ae"></a><!-- doxytag: member="psock::psock_newdata" ref="g3b19f65e48079d8105be2a99b5b4b2ae" args="(struct psock *s)" -->
char&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00158.html#g3b19f65e48079d8105be2a99b5b4b2ae">psock_newdata</a> (struct <a class="el" href="a00082.html">psock</a> *s)</td></tr>
</table>
<hr><h2>Define Documentation</h2>
<a class="anchor" name="g84901a5aa60040e96d272a69977edd22"></a><!-- doxytag: member="psock.h::PSOCK_BEGIN" ref="g84901a5aa60040e96d272a69977edd22" args="(psock)" --><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">#define PSOCK_BEGIN </td>
<td class="md" valign="top">(&nbsp;</td>
<td class="md" nowrap valign="top"><a class="el" href="a00082.html">psock</a>&nbsp;</td>
<td class="mdname1" valign="top" nowrap> </td>
<td class="md" valign="top">&nbsp;)&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>
Start the protosocket protothread in a function.
<p>
This macro starts the protothread associated with the protosocket and must come before other protosocket calls in the function it is used.<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>psock</em>&nbsp;</td><td>(struct psock *) A pointer to the protosocket to be started. </td></tr>
</table>
</dl>
<dl compact><dt><b>Examples: </b></dt><dd>
<a class="el" href="a00036.html#a111">hello-world.c</a>, and <a class="el" href="a00038.html#a166">smtp.c</a>.</dl>
<p>
Definition at line <a class="el" href="a00193.html#l00158">158</a> of file <a class="el" href="a00193.html">psock.h</a>. </td>
</tr>
</table>
<a class="anchor" name="g5d56800f82bfc7bbf53bb4a659589812"></a><!-- doxytag: member="psock.h::PSOCK_CLOSE" ref="g5d56800f82bfc7bbf53bb4a659589812" args="(psock)" --><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">#define PSOCK_CLOSE </td>
<td class="md" valign="top">(&nbsp;</td>
<td class="md" nowrap valign="top"><a class="el" href="a00082.html">psock</a>&nbsp;</td>
<td class="mdname1" valign="top" nowrap> </td>
<td class="md" valign="top">&nbsp;)&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>
Close a protosocket.
<p>
This macro closes a protosocket and can only be called from within the protothread in which the protosocket lives.<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>psock</em>&nbsp;</td><td>(struct psock *) A pointer to the protosocket that is to be closed. </td></tr>
</table>
</dl>
<dl compact><dt><b>Examples: </b></dt><dd>
<a class="el" href="a00036.html#a115">hello-world.c</a>, and <a class="el" href="a00038.html#a169">smtp.c</a>.</dl>
<p>
Definition at line <a class="el" href="a00193.html#l00235">235</a> of file <a class="el" href="a00193.html">psock.h</a>. </td>
</tr>
</table>
<a class="anchor" name="gc7cc1dba1819f7fcdaa9ff9eed5a08f4"></a><!-- doxytag: member="psock.h::PSOCK_CLOSE_EXIT" ref="gc7cc1dba1819f7fcdaa9ff9eed5a08f4" args="(psock)" --><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">#define PSOCK_CLOSE_EXIT </td>
<td class="md" valign="top">(&nbsp;</td>
<td class="md" nowrap valign="top"><a class="el" href="a00082.html">psock</a>&nbsp;</td>
<td class="mdname1" valign="top" nowrap> </td>
<td class="md" valign="top">&nbsp;)&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>
Close a protosocket and exit the protosocket's protothread.
<p>
This macro closes a protosocket and exits the protosocket's protothread.<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>psock</em>&nbsp;</td><td>(struct psock *) A pointer to the protosocket. </td></tr>
</table>
</dl>
<p>
Definition at line <a class="el" href="a00193.html#l00308">308</a> of file <a class="el" href="a00193.html">psock.h</a>. </td>
</tr>
</table>
<a class="anchor" name="g4ab2de595d36e9e55dd61f6ecd139162"></a><!-- doxytag: member="psock.h::PSOCK_DATALEN" ref="g4ab2de595d36e9e55dd61f6ecd139162" args="(psock)" --><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">#define PSOCK_DATALEN </td>
<td class="md" valign="top">(&nbsp;</td>
<td class="md" nowrap valign="top"><a class="el" href="a00082.html">psock</a>&nbsp;</td>
<td class="mdname1" valign="top" nowrap> </td>
<td class="md" valign="top">&nbsp;)&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>
The length of the data that was previously read.
<p>
This macro returns the length of the data that was previously read using <a class="el" href="a00158.html#gb5d9c0becf7cb32d0aaef466839dd92e">PSOCK_READTO()</a> or PSOCK_READ().<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>psock</em>&nbsp;</td><td>(struct psock *) A pointer to the protosocket holding the data. </td></tr>
</table>
</dl>
<p>
Definition at line <a class="el" href="a00193.html#l00281">281</a> of file <a class="el" href="a00193.html">psock.h</a>. </td>
</tr>
</table>
<a class="anchor" name="g4a264bb64ae706d53f572b1d9e4037a2"></a><!-- doxytag: member="psock.h::PSOCK_END" ref="g4a264bb64ae706d53f572b1d9e4037a2" args="(psock)" --><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">#define PSOCK_END </td>
<td class="md" valign="top">(&nbsp;</td>
<td class="md" nowrap valign="top"><a class="el" href="a00082.html">psock</a>&nbsp;</td>
<td class="mdname1" valign="top" nowrap> </td>
<td class="md" valign="top">&nbsp;)&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>
Declare the end of a protosocket's protothread.
<p>
This macro is used for declaring that the protosocket's protothread ends. It must always be used together with a matching <a class="el" href="a00158.html#g84901a5aa60040e96d272a69977edd22">PSOCK_BEGIN()</a> macro.<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>psock</em>&nbsp;</td><td>(struct psock *) A pointer to the protosocket. </td></tr>
</table>
</dl>
<dl compact><dt><b>Examples: </b></dt><dd>
<a class="el" href="a00036.html#a116">hello-world.c</a>, and <a class="el" href="a00038.html#a182">smtp.c</a>.</dl>
<p>
Definition at line <a class="el" href="a00193.html#l00325">325</a> of file <a class="el" href="a00193.html">psock.h</a>. </td>
</tr>
</table>
<a class="anchor" name="gfa11b2a1faf395ae2a6626e01c482d5d"></a><!-- doxytag: member="psock.h::PSOCK_EXIT" ref="gfa11b2a1faf395ae2a6626e01c482d5d" args="(psock)" --><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">#define PSOCK_EXIT </td>
<td class="md" valign="top">(&nbsp;</td>
<td class="md" nowrap valign="top"><a class="el" href="a00082.html">psock</a>&nbsp;</td>
<td class="mdname1" valign="top" nowrap> </td>
<td class="md" valign="top">&nbsp;)&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>
Exit the protosocket's protothread.
<p>
This macro terminates the protothread of the protosocket and should almost always be used in conjunction with <a class="el" href="a00158.html#g5d56800f82bfc7bbf53bb4a659589812">PSOCK_CLOSE()</a>.<p>
<dl compact><dt><b>See also:</b></dt><dd><a class="el" href="a00158.html#gc7cc1dba1819f7fcdaa9ff9eed5a08f4">PSOCK_CLOSE_EXIT()</a></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>psock</em>&nbsp;</td><td>(struct psock *) A pointer to the protosocket. </td></tr>
</table>
</dl>
<dl compact><dt><b>Examples: </b></dt><dd>
<a class="el" href="a00038.html#a171">smtp.c</a>.</dl>
<p>
Definition at line <a class="el" href="a00193.html#l00297">297</a> of file <a class="el" href="a00193.html">psock.h</a>. </td>
</tr>
</table>
<a class="anchor" name="g10d9a9201cba1a6db623284c475c6cea"></a><!-- doxytag: member="psock.h::PSOCK_GENERATOR_SEND" ref="g10d9a9201cba1a6db623284c475c6cea" args="(psock, generator, arg)" --><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">#define PSOCK_GENERATOR_SEND </td>
<td class="md" valign="top">(&nbsp;</td>
<td class="md" nowrap valign="top"><a class="el" href="a00082.html">psock</a>, <tr>
<td class="md" nowrap align="right"></td>
<td class="md"></td>
<td class="md" nowrap>generator, <tr>
<td class="md" nowrap align="right"></td>
<td class="md"></td>
<td class="md" nowrap>arg&nbsp;</td>
<td class="mdname1" valign="top" nowrap> </td>
<td class="md" valign="top">&nbsp;)&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>
Generate data with a function and send it.
<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>psock</em>&nbsp;</td><td>Pointer to the protosocket. </td></tr>
<tr><td valign="top"></td><td valign="top"><em>generator</em>&nbsp;</td><td>Pointer to the generator function </td></tr>
<tr><td valign="top"></td><td valign="top"><em>arg</em>&nbsp;</td><td>Argument to the generator function</td></tr>
</table>
</dl>
This function generates data and sends it over the protosocket. This can be used to dynamically generate data for a transmission, instead of generating the data in a buffer beforehand. This function reduces the need for buffer memory. The generator function is implemented by the application, and a pointer to the function is given as an argument with the call to <a class="el" href="a00158.html#g10d9a9201cba1a6db623284c475c6cea">PSOCK_GENERATOR_SEND()</a>.<p>
The generator function should place the generated data directly in the uip_appdata buffer, and return the length of the generated data. The generator function is called by the protosocket layer when the data first is sent, and once for every retransmission that is needed.
<p>
Definition at line <a class="el" href="a00193.html#l00219">219</a> of file <a class="el" href="a00193.html">psock.h</a>. </td>
</tr>
</table>
<a class="anchor" name="g26ae707402e494f3895a9f012a93ea29"></a><!-- doxytag: member="psock.h::PSOCK_INIT" ref="g26ae707402e494f3895a9f012a93ea29" args="(psock, buffer, buffersize)" --><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">#define PSOCK_INIT </td>
<td class="md" valign="top">(&nbsp;</td>
<td class="md" nowrap valign="top"><a class="el" href="a00082.html">psock</a>, <tr>
<td class="md" nowrap align="right"></td>
<td class="md"></td>
<td class="md" nowrap>buffer, <tr>
<td class="md" nowrap align="right"></td>
<td class="md"></td>
<td class="md" nowrap>buffersize&nbsp;</td>
<td class="mdname1" valign="top" nowrap> </td>
<td class="md" valign="top">&nbsp;)&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>
Initialize a protosocket.
<p>
This macro initializes a protosocket and must be called before the protosocket is used. The initialization also specifies the input buffer for the protosocket.<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>psock</em>&nbsp;</td><td>(struct psock *) A pointer to the protosocket to be initialized</td></tr>
<tr><td valign="top"></td><td valign="top"><em>buffer</em>&nbsp;</td><td>(char *) A pointer to the input buffer for the protosocket.</td></tr>
<tr><td valign="top"></td><td valign="top"><em>buffersize</em>&nbsp;</td><td>(unsigned int) The size of the input buffer. </td></tr>
</table>
</dl>
<dl compact><dt><b>Examples: </b></dt><dd>
<a class="el" href="a00036.html#a108">hello-world.c</a>, and <a class="el" href="a00038.html#a193">smtp.c</a>.</dl>
<p>
Definition at line <a class="el" href="a00193.html#l00144">144</a> of file <a class="el" href="a00193.html">psock.h</a>.
<p>
Referenced by <a class="el" href="a00170.html#l00055">hello_world_appcall()</a>, <a class="el" href="a00184.html#l00298">httpd_appcall()</a>, and <a class="el" href="a00174.html#l00233">smtp_send()</a>. </td>
</tr>
</table>
<a class="anchor" name="g55ce98ea4d6f22e9d5068b904d4d2447"></a><!-- doxytag: member="psock.h::PSOCK_NEWDATA" ref="g55ce98ea4d6f22e9d5068b904d4d2447" args="(psock)" --><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">#define PSOCK_NEWDATA </td>
<td class="md" valign="top">(&nbsp;</td>
<td class="md" nowrap valign="top"><a class="el" href="a00082.html">psock</a>&nbsp;</td>
<td class="mdname1" valign="top" nowrap> </td>
<td class="md" valign="top">&nbsp;)&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>
Check if new data has arrived on a protosocket.
<p>
This macro is used in conjunction with the <a class="el" href="a00158.html#g2ebfe5c8a7f3173714efdf2df74fc392">PSOCK_WAIT_UNTIL()</a> macro to check if data has arrived on a protosocket.<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>psock</em>&nbsp;</td><td>(struct psock *) A pointer to the protosocket. </td></tr>
</table>
</dl>
<p>
Definition at line <a class="el" href="a00193.html#l00339">339</a> of file <a class="el" href="a00193.html">psock.h</a>. </td>
</tr>
</table>
<a class="anchor" name="gd895ab98c54d9966ff554aa873151751"></a><!-- doxytag: member="psock.h::PSOCK_READBUF" ref="gd895ab98c54d9966ff554aa873151751" args="(psock)" --><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">#define PSOCK_READBUF </td>
<td class="md" valign="top">(&nbsp;</td>
<td class="md" nowrap valign="top"><a class="el" href="a00082.html">psock</a>&nbsp;</td>
<td class="mdname1" valign="top" nowrap> </td>
<td class="md" valign="top">&nbsp;)&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>
Read data until the buffer is full.
<p>
This macro will block waiting for data and read the data into the input buffer specified with the call to <a class="el" href="a00158.html#g26ae707402e494f3895a9f012a93ea29">PSOCK_INIT()</a>. Data is read until the buffer is full..<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>psock</em>&nbsp;</td><td>(struct psock *) A pointer to the protosocket from which data should be read. </td></tr>
</table>
</dl>
<p>
Definition at line <a class="el" href="a00193.html#l00250">250</a> of file <a class="el" href="a00193.html">psock.h</a>. </td>
</tr>
</table>
<a class="anchor" name="gb5d9c0becf7cb32d0aaef466839dd92e"></a><!-- doxytag: member="psock.h::PSOCK_READTO" ref="gb5d9c0becf7cb32d0aaef466839dd92e" args="(psock, c)" --><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">#define PSOCK_READTO </td>
<td class="md" valign="top">(&nbsp;</td>
<td class="md" nowrap valign="top"><a class="el" href="a00082.html">psock</a>, <tr>
<td class="md" nowrap align="right"></td>
<td class="md"></td>
<td class="md" nowrap>c&nbsp;</td>
<td class="mdname1" valign="top" nowrap> </td>
<td class="md" valign="top">&nbsp;)&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>
Read data up to a specified character.
<p>
This macro will block waiting for data and read the data into the input buffer specified with the call to <a class="el" href="a00158.html#g26ae707402e494f3895a9f012a93ea29">PSOCK_INIT()</a>. Data is only read until the specifieed character appears in the data stream.<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>psock</em>&nbsp;</td><td>(struct psock *) A pointer to the protosocket from which data should be read.</td></tr>
<tr><td valign="top"></td><td valign="top"><em>c</em>&nbsp;</td><td>(char) The character at which to stop reading. </td></tr>
</table>
</dl>
<dl compact><dt><b>Examples: </b></dt><dd>
<a class="el" href="a00036.html#a113">hello-world.c</a>, and <a class="el" href="a00038.html#a167">smtp.c</a>.</dl>
<p>
Definition at line <a class="el" href="a00193.html#l00268">268</a> of file <a class="el" href="a00193.html">psock.h</a>. </td>
</tr>
</table>
<a class="anchor" name="g70d236d1cf34b4e21836edda60247b70"></a><!-- doxytag: member="psock.h::PSOCK_SEND" ref="g70d236d1cf34b4e21836edda60247b70" args="(psock, data, datalen)" --><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">#define PSOCK_SEND </td>
<td class="md" valign="top">(&nbsp;</td>
<td class="md" nowrap valign="top"><a class="el" href="a00082.html">psock</a>, <tr>
<td class="md" nowrap align="right"></td>
<td class="md"></td>
<td class="md" nowrap>data, <tr>
<td class="md" nowrap align="right"></td>
<td class="md"></td>
<td class="md" nowrap>datalen&nbsp;</td>
<td class="mdname1" valign="top" nowrap> </td>
<td class="md" valign="top">&nbsp;)&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>
Send data.
<p>
This macro sends data over a protosocket. The protosocket protothread blocks until all data has been sent and is known to have been received by the remote end of the TCP connection.<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>psock</em>&nbsp;</td><td>(struct psock *) A pointer to the protosocket over which data is to be sent.</td></tr>
<tr><td valign="top"></td><td valign="top"><em>data</em>&nbsp;</td><td>(char *) A pointer to the data that is to be sent.</td></tr>
<tr><td valign="top"></td><td valign="top"><em>datalen</em>&nbsp;</td><td>(unsigned int) The length of the data that is to be sent. </td></tr>
</table>
</dl>
<dl compact><dt><b>Examples: </b></dt><dd>
<a class="el" href="a00038.html#a178">smtp.c</a>.</dl>
<p>
Definition at line <a class="el" href="a00193.html#l00178">178</a> of file <a class="el" href="a00193.html">psock.h</a>. </td>
</tr>
</table>
<a class="anchor" name="gb0ad55aa96dd1d200cd0fc5a99f6a4f7"></a><!-- doxytag: member="psock.h::PSOCK_SEND_STR" ref="gb0ad55aa96dd1d200cd0fc5a99f6a4f7" args="(psock, str)" --><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">#define PSOCK_SEND_STR </td>
<td class="md" valign="top">(&nbsp;</td>
<td class="md" nowrap valign="top"><a class="el" href="a00082.html">psock</a>, <tr>
<td class="md" nowrap align="right"></td>
<td class="md"></td>
<td class="md" nowrap>str&nbsp;</td>
<td class="mdname1" valign="top" nowrap> </td>
<td class="md" valign="top">&nbsp;)&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>
Send a null-terminated string.
<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>psock</em>&nbsp;</td><td>Pointer to the protosocket. </td></tr>
<tr><td valign="top"></td><td valign="top"><em>str</em>&nbsp;</td><td>The string to be sent.</td></tr>
</table>
</dl>
This function sends a null-terminated string over the protosocket. <dl compact><dt><b>Examples: </b></dt><dd>
<a class="el" href="a00036.html#a112">hello-world.c</a>, and <a class="el" href="a00038.html#a172">smtp.c</a>.</dl>
<p>
Definition at line <a class="el" href="a00193.html#l00191">191</a> of file <a class="el" href="a00193.html">psock.h</a>. </td>
</tr>
</table>
<a class="anchor" name="g2ebfe5c8a7f3173714efdf2df74fc392"></a><!-- doxytag: member="psock.h::PSOCK_WAIT_UNTIL" ref="g2ebfe5c8a7f3173714efdf2df74fc392" args="(psock, condition)" --><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">#define PSOCK_WAIT_UNTIL </td>
<td class="md" valign="top">(&nbsp;</td>
<td class="md" nowrap valign="top"><a class="el" href="a00082.html">psock</a>, <tr>
<td class="md" nowrap align="right"></td>
<td class="md"></td>
<td class="md" nowrap>condition&nbsp;</td>
<td class="mdname1" valign="top" nowrap> </td>
<td class="md" valign="top">&nbsp;)&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>
Wait until a condition is true.
<p>
This macro blocks the protothread until the specified condition is true. The macro <a class="el" href="a00158.html#g55ce98ea4d6f22e9d5068b904d4d2447">PSOCK_NEWDATA()</a> can be used to check if new data arrives when the protosocket is waiting.<p>
Typically, this macro is used as follows:<p>
<div class="fragment"><pre class="fragment"> <a class="code" href="a00142.html#g3d4c8bd4aada659eb34f5d2ffd3e7901">PT_THREAD</a>(thread(<span class="keyword">struct</span> <a class="code" href="a00082.html">psock</a> *s, <span class="keyword">struct</span> <a class="code" href="a00087.html">timer</a> *t))
{
<a class="code" href="a00158.html#g84901a5aa60040e96d272a69977edd22">PSOCK_BEGIN</a>(s);
<a class="code" href="a00158.html#g2ebfe5c8a7f3173714efdf2df74fc392">PSOCK_WAIT_UNTIL</a>(s, PSOCK_NEWADATA(s) || <a class="code" href="a00156.html#g6d71dececfce707c668e6257aad5906e">timer_expired</a>(t));
<span class="keywordflow">if</span>(<a class="code" href="a00158.html#g55ce98ea4d6f22e9d5068b904d4d2447">PSOCK_NEWDATA</a>(s)) {
<a class="code" href="a00158.html#gb5d9c0becf7cb32d0aaef466839dd92e">PSOCK_READTO</a>(s, <span class="charliteral">'\n'</span>);
} <span class="keywordflow">else</span> {
handle_timed_out(s);
}
<a class="code" href="a00158.html#g4a264bb64ae706d53f572b1d9e4037a2">PSOCK_END</a>(s);
}
</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>psock</em>&nbsp;</td><td>(struct psock *) A pointer to the protosocket. </td></tr>
<tr><td valign="top"></td><td valign="top"><em>condition</em>&nbsp;</td><td>The condition to wait for. </td></tr>
</table>
</dl>
<p>
Definition at line <a class="el" href="a00193.html#l00372">372</a> of file <a class="el" href="a00193.html">psock.h</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&nbsp;
<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>