1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
|
<!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>anytun: UDPSocket Class Reference</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.5.1 -->
<div class="tabs">
<ul>
<li><a href="main.html"><span>Main Page</span></a></li>
<li><a href="namespaces.html"><span>Namespaces</span></a></li>
<li id="current"><a href="annotated.html"><span>Classes</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
</ul></div>
<div class="tabs">
<ul>
<li><a href="annotated.html"><span>Class List</span></a></li>
<li><a href="hierarchy.html"><span>Class Hierarchy</span></a></li>
<li><a href="functions.html"><span>Class Members</span></a></li>
</ul></div>
<h1>UDPSocket Class Reference</h1><!-- doxytag: class="UDPSocket" --><!-- doxytag: inherits="CommunicatingSocket" --><code>#include <<a class="el" href="PracticalSocket_8h-source.html">PracticalSocket.h</a>></code>
<p>
<p>Inheritance diagram for UDPSocket:
<p><center><img src="classUDPSocket.png" usemap="#UDPSocket_map" border="0" alt=""></center>
<map name="UDPSocket_map">
<area href="classCommunicatingSocket.html" alt="CommunicatingSocket" shape="rect" coords="0,56,135,80">
<area href="classSocket.html" alt="Socket" shape="rect" coords="0,0,135,24">
<area href="classUDPPacketSource.html" alt="UDPPacketSource" shape="rect" coords="0,168,135,192">
</map>
<a href="classUDPSocket-members.html">List of all members.</a><table border="0" cellpadding="0" cellspacing="0">
<tr><td></td></tr>
<tr><td colspan="2"><br><h2>Public Member Functions</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"> </td><td class="memItemRight" valign="bottom"><a class="el" href="classUDPSocket.html#4f86f3023f5a08f6355802599a10e100">UDPSocket</a> () throw (SocketException)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"> </td><td class="memItemRight" valign="bottom"><a class="el" href="classUDPSocket.html#14dcb55c4b60b12d4a7fff648cbb825f">UDPSocket</a> (unsigned short localPort) throw (SocketException)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"> </td><td class="memItemRight" valign="bottom"><a class="el" href="classUDPSocket.html#f19281c523f15ed30d7d78f09033713d">UDPSocket</a> (const string &localAddress, unsigned short localPort) throw (SocketException)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="classUDPSocket.html#7482e8e61cef160e1a7c0d6ac15c01be">disconnect</a> () throw (SocketException)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="classUDPSocket.html#41a3595e226f273953cbd38618af5d5b">sendTo</a> (const void *buffer, int bufferLen, const string &foreignAddress, unsigned short foreignPort) throw (SocketException)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="classUDPSocket.html#bcd5c064e2496bd8b1888fd4e1b68949">recvFrom</a> (void *buffer, int bufferLen, string &sourceAddress, unsigned short &sourcePort) throw (SocketException)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="classUDPSocket.html#4dcfff33b45d1b84b5a602fc6f4a27f8">setMulticastTTL</a> (unsigned char multicastTTL) throw (SocketException)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="classUDPSocket.html#1b20c1e8bd49a9bd9b53dd4f1c8d4c11">joinGroup</a> (const string &multicastGroup) throw (SocketException)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="classUDPSocket.html#78835eaeca8a5ac039b4579c795e3640">leaveGroup</a> (const string &multicastGroup) throw (SocketException)</td></tr>
<tr><td colspan="2"><br><h2>Private Member Functions</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="classUDPSocket.html#316f08a017aa160643812f3c08734d27">setBroadcast</a> ()</td></tr>
</table>
<hr><a name="_details"></a><h2>Detailed Description</h2>
UDP socket class
<p>
<hr><h2>Constructor & Destructor Documentation</h2>
<a class="anchor" name="4f86f3023f5a08f6355802599a10e100"></a><!-- doxytag: member="UDPSocket::UDPSocket" ref="4f86f3023f5a08f6355802599a10e100" args="()" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">UDPSocket::UDPSocket </td>
<td>(</td>
<td class="paramname"> </td>
<td> ) </td>
<td width="100%"> throw (<a class="el" href="classSocketException.html">SocketException</a>)</td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Construct a UDP socket <dl compact><dt><b>Exceptions:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em><a class="el" href="classSocketException.html">SocketException</a></em> </td><td>thrown if unable to create UDP socket </td></tr>
</table>
</dl>
</div>
</div><p>
<a class="anchor" name="14dcb55c4b60b12d4a7fff648cbb825f"></a><!-- doxytag: member="UDPSocket::UDPSocket" ref="14dcb55c4b60b12d4a7fff648cbb825f" args="(unsigned short localPort)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">UDPSocket::UDPSocket </td>
<td>(</td>
<td class="paramtype">unsigned short </td>
<td class="paramname"> <em>localPort</em> </td>
<td> ) </td>
<td width="100%"> throw (<a class="el" href="classSocketException.html">SocketException</a>)</td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Construct a UDP socket with the given local port <dl compact><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em>localPort</em> </td><td>local port </td></tr>
</table>
</dl>
<dl compact><dt><b>Exceptions:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em><a class="el" href="classSocketException.html">SocketException</a></em> </td><td>thrown if unable to create UDP socket </td></tr>
</table>
</dl>
</div>
</div><p>
<a class="anchor" name="f19281c523f15ed30d7d78f09033713d"></a><!-- doxytag: member="UDPSocket::UDPSocket" ref="f19281c523f15ed30d7d78f09033713d" args="(const string &localAddress, unsigned short localPort)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">UDPSocket::UDPSocket </td>
<td>(</td>
<td class="paramtype">const string & </td>
<td class="paramname"> <em>localAddress</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">unsigned short </td>
<td class="paramname"> <em>localPort</em></td><td> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td width="100%"> throw (<a class="el" href="classSocketException.html">SocketException</a>)</td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Construct a UDP socket with the given local port and address <dl compact><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em>localAddress</em> </td><td>local address </td></tr>
<tr><td valign="top"></td><td valign="top"><em>localPort</em> </td><td>local port </td></tr>
</table>
</dl>
<dl compact><dt><b>Exceptions:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em><a class="el" href="classSocketException.html">SocketException</a></em> </td><td>thrown if unable to create UDP socket </td></tr>
</table>
</dl>
</div>
</div><p>
<hr><h2>Member Function Documentation</h2>
<a class="anchor" name="7482e8e61cef160e1a7c0d6ac15c01be"></a><!-- doxytag: member="UDPSocket::disconnect" ref="7482e8e61cef160e1a7c0d6ac15c01be" args="()" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void UDPSocket::disconnect </td>
<td>(</td>
<td class="paramname"> </td>
<td> ) </td>
<td width="100%"> throw (<a class="el" href="classSocketException.html">SocketException</a>)</td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Unset foreign address and port <dl class="return" compact><dt><b>Returns:</b></dt><dd>true if disassociation is successful </dd></dl>
<dl compact><dt><b>Exceptions:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em><a class="el" href="classSocketException.html">SocketException</a></em> </td><td>thrown if unable to disconnect UDP socket </td></tr>
</table>
</dl>
</div>
</div><p>
<a class="anchor" name="41a3595e226f273953cbd38618af5d5b"></a><!-- doxytag: member="UDPSocket::sendTo" ref="41a3595e226f273953cbd38618af5d5b" args="(const void *buffer, int bufferLen, const string &foreignAddress, unsigned short foreignPort)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void UDPSocket::sendTo </td>
<td>(</td>
<td class="paramtype">const void * </td>
<td class="paramname"> <em>buffer</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int </td>
<td class="paramname"> <em>bufferLen</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const string & </td>
<td class="paramname"> <em>foreignAddress</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">unsigned short </td>
<td class="paramname"> <em>foreignPort</em></td><td> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td width="100%"> throw (<a class="el" href="classSocketException.html">SocketException</a>)</td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Send the given buffer as a UDP datagram to the specified address/port <dl compact><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em>buffer</em> </td><td>buffer to be written </td></tr>
<tr><td valign="top"></td><td valign="top"><em>bufferLen</em> </td><td>number of bytes to write </td></tr>
<tr><td valign="top"></td><td valign="top"><em>foreignAddress</em> </td><td>address (IP address or name) to send to </td></tr>
<tr><td valign="top"></td><td valign="top"><em>foreignPort</em> </td><td>port number to send to </td></tr>
</table>
</dl>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>true if send is successful </dd></dl>
<dl compact><dt><b>Exceptions:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em><a class="el" href="classSocketException.html">SocketException</a></em> </td><td>thrown if unable to send datagram </td></tr>
</table>
</dl>
</div>
</div><p>
<a class="anchor" name="bcd5c064e2496bd8b1888fd4e1b68949"></a><!-- doxytag: member="UDPSocket::recvFrom" ref="bcd5c064e2496bd8b1888fd4e1b68949" args="(void *buffer, int bufferLen, string &sourceAddress, unsigned short &sourcePort)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int UDPSocket::recvFrom </td>
<td>(</td>
<td class="paramtype">void * </td>
<td class="paramname"> <em>buffer</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int </td>
<td class="paramname"> <em>bufferLen</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">string & </td>
<td class="paramname"> <em>sourceAddress</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">unsigned short & </td>
<td class="paramname"> <em>sourcePort</em></td><td> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td width="100%"> throw (<a class="el" href="classSocketException.html">SocketException</a>)</td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Read read up to bufferLen bytes data from this socket. The given buffer is where the data will be placed <dl compact><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em>buffer</em> </td><td>buffer to receive data </td></tr>
<tr><td valign="top"></td><td valign="top"><em>bufferLen</em> </td><td>maximum number of bytes to receive </td></tr>
<tr><td valign="top"></td><td valign="top"><em>sourceAddress</em> </td><td>address of datagram source </td></tr>
<tr><td valign="top"></td><td valign="top"><em>sourcePort</em> </td><td>port of data source </td></tr>
</table>
</dl>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>number of bytes received and -1 for error </dd></dl>
<dl compact><dt><b>Exceptions:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em><a class="el" href="classSocketException.html">SocketException</a></em> </td><td>thrown if unable to receive datagram </td></tr>
</table>
</dl>
</div>
</div><p>
<a class="anchor" name="4dcfff33b45d1b84b5a602fc6f4a27f8"></a><!-- doxytag: member="UDPSocket::setMulticastTTL" ref="4dcfff33b45d1b84b5a602fc6f4a27f8" args="(unsigned char multicastTTL)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void UDPSocket::setMulticastTTL </td>
<td>(</td>
<td class="paramtype">unsigned char </td>
<td class="paramname"> <em>multicastTTL</em> </td>
<td> ) </td>
<td width="100%"> throw (<a class="el" href="classSocketException.html">SocketException</a>)</td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Set the multicast TTL <dl compact><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em>multicastTTL</em> </td><td>multicast TTL </td></tr>
</table>
</dl>
<dl compact><dt><b>Exceptions:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em><a class="el" href="classSocketException.html">SocketException</a></em> </td><td>thrown if unable to set TTL </td></tr>
</table>
</dl>
</div>
</div><p>
<a class="anchor" name="1b20c1e8bd49a9bd9b53dd4f1c8d4c11"></a><!-- doxytag: member="UDPSocket::joinGroup" ref="1b20c1e8bd49a9bd9b53dd4f1c8d4c11" args="(const string &multicastGroup)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void UDPSocket::joinGroup </td>
<td>(</td>
<td class="paramtype">const string & </td>
<td class="paramname"> <em>multicastGroup</em> </td>
<td> ) </td>
<td width="100%"> throw (<a class="el" href="classSocketException.html">SocketException</a>)</td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Join the specified multicast group <dl compact><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em>multicastGroup</em> </td><td>multicast group address to join </td></tr>
</table>
</dl>
<dl compact><dt><b>Exceptions:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em><a class="el" href="classSocketException.html">SocketException</a></em> </td><td>thrown if unable to join group </td></tr>
</table>
</dl>
</div>
</div><p>
<a class="anchor" name="78835eaeca8a5ac039b4579c795e3640"></a><!-- doxytag: member="UDPSocket::leaveGroup" ref="78835eaeca8a5ac039b4579c795e3640" args="(const string &multicastGroup)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void UDPSocket::leaveGroup </td>
<td>(</td>
<td class="paramtype">const string & </td>
<td class="paramname"> <em>multicastGroup</em> </td>
<td> ) </td>
<td width="100%"> throw (<a class="el" href="classSocketException.html">SocketException</a>)</td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Leave the specified multicast group <dl compact><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em>multicastGroup</em> </td><td>multicast group address to leave </td></tr>
</table>
</dl>
<dl compact><dt><b>Exceptions:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em><a class="el" href="classSocketException.html">SocketException</a></em> </td><td>thrown if unable to leave group </td></tr>
</table>
</dl>
</div>
</div><p>
<a class="anchor" name="316f08a017aa160643812f3c08734d27"></a><!-- doxytag: member="UDPSocket::setBroadcast" ref="316f08a017aa160643812f3c08734d27" args="()" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void UDPSocket::setBroadcast </td>
<td>(</td>
<td class="paramname"> </td>
<td> ) </td>
<td width="100%"><code> [private]</code></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
</div>
</div><p>
<hr>The documentation for this class was generated from the following files:<ul>
<li><a class="el" href="PracticalSocket_8h-source.html">PracticalSocket.h</a><li><a class="el" href="PracticalSocket_8cpp.html">PracticalSocket.cpp</a></ul>
<hr size="1"><address style="align: right;"><small>Generated on Sun Oct 7 23:43:50 2007 for anytun by
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.1 </small></address>
</body>
</html>
|