1 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> |
2 |
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"> |
3 |
<title>PEAK Library: Socket streams</title> |
4 |
<link href="doxygen.css" rel="stylesheet" type="text/css"> |
5 |
</head><body> |
6 |
<!-- Generated by Doxygen 1.3.5 --> |
7 |
<div class="qindex"><a class="qindex" href="index.html">Main Page</a> | <a class="qindex" href="modules.html">Modules</a> | <a class="qindex" href="annotated.html">Data Structures</a> | <a class="qindex" href="functions.html">Data Fields</a></div> |
8 |
<h1>Socket streams</h1><hr><a name="_details"></a><h2>Detailed Description</h2> |
9 |
This API provides a functional interface to asynchronously processed socket streams. For simplicity, unlike other implementations, one stream instance can be readable and writable at the same time. Once configured, a stream must be scheduled with a task. The library will then notify the application using a notification callback, which will be called by one of the task's thread. |
10 |
<p> |
11 |
<table border=0 cellpadding=0 cellspacing=0> |
12 |
<tr><td></td></tr> |
13 |
<tr><td colspan=2><br><h2>Modules</h2></td></tr> |
14 |
<tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="group__stream__common.html">Stream common</a></td></tr> |
15 |
|
16 |
<tr><td class="mdescLeft"> </td><td class="mdescRight">Creation methods and other common methods for socket streams. <br><br></td></tr> |
17 |
|
18 |
<p> |
19 |
<tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="group__stream__low.html">Non-buffered operations</a></td></tr> |
20 |
|
21 |
<tr><td class="mdescLeft"> </td><td class="mdescRight">Low level read/write primitives. <br><br></td></tr> |
22 |
|
23 |
<p> |
24 |
<tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="group__stream__line.html">Line-mode operations</a></td></tr> |
25 |
|
26 |
<tr><td class="mdescLeft"> </td><td class="mdescRight">Line-mode based stream methods. <br><br></td></tr> |
27 |
|
28 |
<p> |
29 |
<tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="group__stream__buf.html">Write-buffered operations</a></td></tr> |
30 |
|
31 |
<tr><td class="mdescLeft"> </td><td class="mdescRight">Write-buffered stream methods. <br><br></td></tr> |
32 |
|
33 |
<p> |
34 |
<tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="group__stream__sched.html">Scheduling</a></td></tr> |
35 |
|
36 |
<tr><td class="mdescLeft"> </td><td class="mdescRight">Scheduling task for streams. <br><br></td></tr> |
37 |
|
38 |
<p> |
39 |
<tr><td colspan=2><br><h2>Typedefs</h2></td></tr> |
40 |
<tr><td class="memItemLeft" nowrap align=right valign=top><a class="anchor" name="ga0" doxytag="stream::peak_stream" ></a> |
41 |
typedef __peak_stream * </td><td class="memItemRight" valign=bottom><a class="el" href="group__stream.html#ga0">peak_stream</a></td></tr> |
42 |
|
43 |
<tr><td class="mdescLeft"> </td><td class="mdescRight">Opaque stream pointer type. <br><br></td></tr> |
44 |
<tr><td class="memItemLeft" nowrap align=right valign=top>typedef void(* </td><td class="memItemRight" valign=bottom><a class="el" href="group__stream.html#ga1">peak_stream_event_callback</a> )(<a class="el" href="group__stream.html#ga0">peak_stream</a> s, int type, void *context)</td></tr> |
45 |
|
46 |
<tr><td class="mdescLeft"> </td><td class="mdescRight">Stream client event callback. <a href="#ga1"></a><br><br></td></tr> |
47 |
<tr><td colspan=2><br><h2>Enumerations</h2></td></tr> |
48 |
<tr><td class="memItemLeft" nowrap align=right valign=top>enum </td><td class="memItemRight" valign=bottom>{ <br> |
49 |
<a class="el" href="group__stream.html#gga2a5">PEAK_STREAM_OPT_DEFAULT</a> = 0, |
50 |
<br> |
51 |
<a class="el" href="group__stream.html#gga2a6">PEAK_STREAM_OPT_DGRAM</a> = 1 << 0, |
52 |
<br> |
53 |
<a class="el" href="group__stream.html#gga2a7">PEAK_STREAM_OPT_LISTEN</a> = 1 << 1, |
54 |
<br> |
55 |
<a class="el" href="group__stream.html#gga2a8">PEAK_STREAM_OPT_LINEMODE</a> = 1 << 2, |
56 |
<br> |
57 |
<a class="el" href="group__stream.html#gga2a9">PEAK_STREAM_OPT_AUTOSCHEDULE</a> = 1 << 3 |
58 |
<br> |
59 |
}</td></tr> |
60 |
|
61 |
<tr><td class="mdescLeft"> </td><td class="mdescRight">Stream creation options. <a href="#ga2">More...</a><br><br></td></tr> |
62 |
<tr><td class="memItemLeft" nowrap align=right valign=top>enum </td><td class="memItemRight" valign=bottom>{ <br> |
63 |
<a class="el" href="group__stream.html#gga3a10">PEAK_STREAM_EVT_NONE</a> = 0, |
64 |
<br> |
65 |
<a class="el" href="group__stream.html#gga3a11">PEAK_STREAM_EVT_OPEN</a>, |
66 |
<br> |
67 |
<a class="el" href="group__stream.html#gga3a12">PEAK_STREAM_EVT_ACCEPT</a>, |
68 |
<br> |
69 |
<a class="el" href="group__stream.html#gga3a13">PEAK_STREAM_EVT_READ</a>, |
70 |
<br> |
71 |
<a class="el" href="group__stream.html#gga3a14">PEAK_STREAM_EVT_WRITE</a>, |
72 |
<br> |
73 |
<a class="el" href="group__stream.html#gga3a15">PEAK_STREAM_EVT_END</a>, |
74 |
<br> |
75 |
<a class="el" href="group__stream.html#gga3a16">PEAK_STREAM_EVT_ERROR</a>, |
76 |
<br> |
77 |
<a class="el" href="group__stream.html#gga3a17">PEAK_STREAM_EVT_TIMEDOUT</a> |
78 |
<br> |
79 |
}</td></tr> |
80 |
|
81 |
<tr><td class="mdescLeft"> </td><td class="mdescRight">Types of event passed to your stream event callback function. <a href="#ga3">More...</a><br><br></td></tr> |
82 |
</table> |
83 |
<hr><h2>Typedef Documentation</h2> |
84 |
<a class="anchor" name="ga1" doxytag="stream.h::peak_stream_event_callback" ></a><p> |
85 |
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> |
86 |
<tr> |
87 |
<td class="mdRow"> |
88 |
<table cellpadding="0" cellspacing="0" border="0"> |
89 |
<tr> |
90 |
<td class="md" nowrap valign="top"> typedef void(* <a class="el" href="group__stream.html#ga1">peak_stream_event_callback</a>)(<a class="el" href="group__stream.html#ga0">peak_stream</a> s, int type, void *context) |
91 |
</table> |
92 |
</td> |
93 |
</tr> |
94 |
</table> |
95 |
<table cellspacing=5 cellpadding=0 border=0> |
96 |
<tr> |
97 |
<td> |
98 |
|
99 |
</td> |
100 |
<td> |
101 |
|
102 |
<p> |
103 |
Stream client event callback. |
104 |
<p> |
105 |
Defines a pointer to your notification callback function that handles interesting events that occur on a scheduled stream. </td> |
106 |
</tr> |
107 |
</table> |
108 |
<hr><h2>Enumeration Type Documentation</h2> |
109 |
<a class="anchor" name="ga2" doxytag="stream.h::@4" ></a><p> |
110 |
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> |
111 |
<tr> |
112 |
<td class="mdRow"> |
113 |
<table cellpadding="0" cellspacing="0" border="0"> |
114 |
<tr> |
115 |
<td class="md" nowrap valign="top"> anonymous enum |
116 |
</table> |
117 |
</td> |
118 |
</tr> |
119 |
</table> |
120 |
<table cellspacing=5 cellpadding=0 border=0> |
121 |
<tr> |
122 |
<td> |
123 |
|
124 |
</td> |
125 |
<td> |
126 |
|
127 |
<p> |
128 |
Stream creation options. |
129 |
<p> |
130 |
<dl compact><dt><b>Enumeration values: </b></dt><dd> |
131 |
<table border=0 cellspacing=2 cellpadding=0> |
132 |
<tr><td valign=top><em><a class="anchor" name="gga2a5" doxytag="PEAK_STREAM_OPT_DEFAULT" ></a>PEAK_STREAM_OPT_DEFAULT</em> </td><td> |
133 |
Default: SOCK_STREAM socket (reliable stream), ie. TCP. </td></tr> |
134 |
<tr><td valign=top><em><a class="anchor" name="gga2a6" doxytag="PEAK_STREAM_OPT_DGRAM" ></a>PEAK_STREAM_OPT_DGRAM</em> </td><td> |
135 |
UDP socket stream (not a reliable stream). </td></tr> |
136 |
<tr><td valign=top><em><a class="anchor" name="gga2a7" doxytag="PEAK_STREAM_OPT_LISTEN" ></a>PEAK_STREAM_OPT_LISTEN</em> </td><td> |
137 |
Listening socket stream. Will use the address argument as the local address (where to bind). </td></tr> |
138 |
<tr><td valign=top><em><a class="anchor" name="gga2a8" doxytag="PEAK_STREAM_OPT_LINEMODE" ></a>PEAK_STREAM_OPT_LINEMODE</em> </td><td> |
139 |
Line mode, useful for line-based text streams; the callback is called for every line received. </td></tr> |
140 |
<tr><td valign=top><em><a class="anchor" name="gga2a9" doxytag="PEAK_STREAM_OPT_AUTOSCHEDULE" ></a>PEAK_STREAM_OPT_AUTOSCHEDULE</em> </td><td> |
141 |
Auto schedule, avoid a call to peak_stream_schedule. Useful for accepted socket. </td></tr> |
142 |
</table> |
143 |
</dl> |
144 |
</td> |
145 |
</tr> |
146 |
</table> |
147 |
<a class="anchor" name="ga3" doxytag="stream.h::@5" ></a><p> |
148 |
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> |
149 |
<tr> |
150 |
<td class="mdRow"> |
151 |
<table cellpadding="0" cellspacing="0" border="0"> |
152 |
<tr> |
153 |
<td class="md" nowrap valign="top"> anonymous enum |
154 |
</table> |
155 |
</td> |
156 |
</tr> |
157 |
</table> |
158 |
<table cellspacing=5 cellpadding=0 border=0> |
159 |
<tr> |
160 |
<td> |
161 |
|
162 |
</td> |
163 |
<td> |
164 |
|
165 |
<p> |
166 |
Types of event passed to your stream event callback function. |
167 |
<p> |
168 |
<dl compact><dt><b>Enumeration values: </b></dt><dd> |
169 |
<table border=0 cellspacing=2 cellpadding=0> |
170 |
<tr><td valign=top><em><a class="anchor" name="gga3a10" doxytag="PEAK_STREAM_EVT_NONE" ></a>PEAK_STREAM_EVT_NONE</em> </td><td> |
171 |
Never used. </td></tr> |
172 |
<tr><td valign=top><em><a class="anchor" name="gga3a11" doxytag="PEAK_STREAM_EVT_OPEN" ></a>PEAK_STREAM_EVT_OPEN</em> </td><td> |
173 |
Open event. The stream is now open (connection established). </td></tr> |
174 |
<tr><td valign=top><em><a class="anchor" name="gga3a12" doxytag="PEAK_STREAM_EVT_ACCEPT" ></a>PEAK_STREAM_EVT_ACCEPT</em> </td><td> |
175 |
Accept event. A new stream can be created using <a class="el" href="group__stream__common.html#ga32">peak_stream_accept_create()</a>. </td></tr> |
176 |
<tr><td valign=top><em><a class="anchor" name="gga3a13" doxytag="PEAK_STREAM_EVT_READ" ></a>PEAK_STREAM_EVT_READ</em> </td><td> |
177 |
Read event. There's something to read on the stream. |
178 |
<p> |
179 |
Until you don't really read it, you won't be notified again with this event type. </td></tr> |
180 |
<tr><td valign=top><em><a class="anchor" name="gga3a14" doxytag="PEAK_STREAM_EVT_WRITE" ></a>PEAK_STREAM_EVT_WRITE</em> </td><td> |
181 |
Write event. You can efficiently write on the stream NOW. |
182 |
<p> |
183 |
Until you don't really write something, you won't be notified again with this event type. </td></tr> |
184 |
<tr><td valign=top><em><a class="anchor" name="gga3a15" doxytag="PEAK_STREAM_EVT_END" ></a>PEAK_STREAM_EVT_END</em> </td><td> |
185 |
End of stream event. No further bytes can be read/written. |
186 |
<p> |
187 |
You should release the stream with <a class="el" href="group__alloc.html#ga7">peak_release()</a>. </td></tr> |
188 |
<tr><td valign=top><em><a class="anchor" name="gga3a16" doxytag="PEAK_STREAM_EVT_ERROR" ></a>PEAK_STREAM_EVT_ERROR</em> </td><td> |
189 |
An error occured on the stream's connection. |
190 |
<p> |
191 |
You should release the stream with <a class="el" href="group__alloc.html#ga7">peak_release()</a>. </td></tr> |
192 |
<tr><td valign=top><em><a class="anchor" name="gga3a17" doxytag="PEAK_STREAM_EVT_TIMEDOUT" ></a>PEAK_STREAM_EVT_TIMEDOUT</em> </td><td> |
193 |
Stream's event timed out. |
194 |
<p> |
195 |
Sent only when you enable stream's event timeout checking with <a class="el" href="group__stream__common.html#ga53">peak_stream_set_timeout()</a>. You might release the stream with <a class="el" href="group__alloc.html#ga7">peak_release()</a>. If you ignore it, another event of type <em>PEAK_STREAM_EVT_TIMEDOUT</em> will be sent after <code>timeout</code> seconds as defined in <a class="el" href="group__stream__common.html#ga53">peak_stream_set_timeout()</a>. </td></tr> |
196 |
</table> |
197 |
</dl> |
198 |
</td> |
199 |
</tr> |
200 |
</table> |
201 |
<hr size="1"><address style="align: right;"><small>Generated on Sat Jan 17 21:41:54 2004 for the PEAK Library by |
202 |
<a href="http://www.doxygen.org/index.html"> |
203 |
<img src="doxygen.png" alt="doxygen" align="middle" border="0" > |
204 |
</a></small> <a href="http://sourceforge.net"><img src="http://sourceforge.net/sflogo.php?group_id=98146&type=1" width="88" height="31" align="middle" border="0" alt="SourceForge.net Logo" /></a></address> |
205 |
</body> |
206 |
</html> |
207 |
|