/usr/share/gtk-doc/html/gnet/gnet-udp.html is in libgnet-dev 2.0.8-2.2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>UDP</title>
<meta name="generator" content="DocBook XSL Stylesheets V1.72.0">
<link rel="start" href="index.html" title="GNet Network Library Reference Manual">
<link rel="up" href="libgnet-reference.html" title="GNet Library Reference">
<link rel="prev" href="gnet-tcp.html" title="TCP">
<link rel="next" href="gnet-mcast.html" title="Mcast">
<meta name="generator" content="GTK-Doc V1.8 (XML mode)">
<link rel="stylesheet" href="style.css" type="text/css">
<link rel="chapter" href="gnet-overview.html" title="GNet Overview">
<link rel="chapter" href="gnet-developers.html" title="GNet for developers">
<link rel="chapter" href="gnet-examples.html" title="GNet Examples">
<link rel="chapter" href="libgnet-reference.html" title="GNet Library Reference">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2">
<tr valign="middle">
<td><a accesskey="p" href="gnet-tcp.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td>
<td><a accesskey="u" href="libgnet-reference.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td>
<td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td>
<th width="100%" align="center">GNet Network Library Reference Manual</th>
<td><a accesskey="n" href="gnet-mcast.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
</tr>
<tr><td colspan="5" class="shortcuts"><nobr><a href="#id350294" class="shortcut">Top</a>
 | 
<a href="#id350992" class="shortcut">Description</a></nobr></td></tr>
</table>
<div class="refentry" lang="en">
<a name="gnet-udp"></a><div class="titlepage"></div>
<div class="refnamediv"><table width="100%"><tr>
<td valign="top">
<h2>
<a name="id350294"></a><span class="refentrytitle">UDP</span>
</h2>
<p>UDP — UDP socket</p>
</td>
<td valign="top" align="right"></td>
</tr></table></div>
<div class="refsynopsisdiv">
<h2>Synopsis</h2>
<pre class="synopsis">
#include <gnet.h>
<a href="gnet-udp.html#GUdpSocket">GUdpSocket</a>;
<a href="gnet-udp.html#GUdpSocket">GUdpSocket</a>* <a href="gnet-udp.html#gnet-udp-socket-new">gnet_udp_socket_new</a> (void);
<a href="gnet-udp.html#GUdpSocket">GUdpSocket</a>* <a href="gnet-udp.html#gnet-udp-socket-new-with-port">gnet_udp_socket_new_with_port</a> (gint port);
<a href="gnet-udp.html#GUdpSocket">GUdpSocket</a>* <a href="gnet-udp.html#gnet-udp-socket-new-full">gnet_udp_socket_new_full</a> (const <a href="gnet-inetaddr.html#GInetAddr">GInetAddr</a> *iface,
gint port);
void <a href="gnet-udp.html#gnet-udp-socket-delete">gnet_udp_socket_delete</a> (<a href="gnet-udp.html#GUdpSocket">GUdpSocket</a> *socket);
void <a href="gnet-udp.html#gnet-udp-socket-ref">gnet_udp_socket_ref</a> (<a href="gnet-udp.html#GUdpSocket">GUdpSocket</a> *socket);
void <a href="gnet-udp.html#gnet-udp-socket-unref">gnet_udp_socket_unref</a> (<a href="gnet-udp.html#GUdpSocket">GUdpSocket</a> *socket);
gint <a href="gnet-udp.html#gnet-udp-socket-send">gnet_udp_socket_send</a> (<a href="gnet-udp.html#GUdpSocket">GUdpSocket</a> *socket,
const gchar *buffer,
gint length,
const <a href="gnet-inetaddr.html#GInetAddr">GInetAddr</a> *dst);
gint <a href="gnet-udp.html#gnet-udp-socket-receive">gnet_udp_socket_receive</a> (<a href="gnet-udp.html#GUdpSocket">GUdpSocket</a> *socket,
gchar *buffer,
gint length,
<a href="gnet-inetaddr.html#GInetAddr">GInetAddr</a> **src);
gboolean <a href="gnet-udp.html#gnet-udp-socket-has-packet">gnet_udp_socket_has_packet</a> (const <a href="gnet-udp.html#GUdpSocket">GUdpSocket</a> *socket);
GIOChannel* <a href="gnet-udp.html#gnet-udp-socket-get-io-channel">gnet_udp_socket_get_io_channel</a> (<a href="gnet-udp.html#GUdpSocket">GUdpSocket</a> *socket);
<a href="gnet-inetaddr.html#GInetAddr">GInetAddr</a>* <a href="gnet-udp.html#gnet-udp-socket-get-local-inetaddr">gnet_udp_socket_get_local_inetaddr</a> (const <a href="gnet-udp.html#GUdpSocket">GUdpSocket</a> *socket);
gint <a href="gnet-udp.html#gnet-udp-socket-get-ttl">gnet_udp_socket_get_ttl</a> (const <a href="gnet-udp.html#GUdpSocket">GUdpSocket</a> *socket);
gint <a href="gnet-udp.html#gnet-udp-socket-set-ttl">gnet_udp_socket_set_ttl</a> (<a href="gnet-udp.html#GUdpSocket">GUdpSocket</a> *socket,
gint ttl);
</pre>
</div>
<div class="refsect1" lang="en">
<a name="id350992"></a><h2>Description</h2>
<p>
This module provides support for UDP sockets. UDP is an internet
protocol that transfers packets by best-effort delivery. Packets may
be lost or arrive out-of-order. Use TCP if your protocol requires
data transfered reliably and in-order -- most do.
</p>
<p>
A UDP socket is represented by a <a href="gnet-udp.html#GUdpSocket"><span class="type">GUdpSocket</span></a> structure. To create a
<a href="gnet-udp.html#GUdpSocket"><span class="type">GUdpSocket</span></a>, call <a href="gnet-udp.html#gnet-udp-socket-new"><code class="function">gnet_udp_socket_new()</code></a>,
<a href="gnet-udp.html#gnet-udp-socket-new-with-port"><code class="function">gnet_udp_socket_new_with_port()</code></a>, or <a href="gnet-udp.html#gnet-udp-socket-new-full"><code class="function">gnet_udp_socket_new_full()</code></a>.
</p>
<p>
To send a packet, call <a href="gnet-udp.html#gnet-udp-socket-send"><code class="function">gnet_udp_socket_send()</code></a>. To receive a packet,
call <a href="gnet-udp.html#gnet-udp-socket-receive"><code class="function">gnet_udp_socket_receive()</code></a>. <a href="gnet-udp.html#gnet-udp-socket-send"><code class="function">gnet_udp_socket_send()</code></a> will block if
the OS cannot buffer the packet immediately.
<a href="gnet-udp.html#gnet-udp-socket-receive"><code class="function">gnet_udp_socket_receive()</code></a> will block until there is a packet available
to receive. Call <a href="gnet-udp.html#gnet-udp-socket-has-packet"><code class="function">gnet_udp_socket_has_packet()</code></a> to determine whether a
packet is available immediately. A more elegant method is to get the
<span class="type">GIOChannel</span> and add a read watch. A callback will be called when a
packet is available. Note that a UDP socket's <span class="type">GIOChannel</span> is not a
normal <span class="type">GIOChannel</span> -- it should not be written to or read from
directly.
</p>
<p>
Packets have a time-to-live (TTL) field. This field is decremented
before a router forwards the packet. If the TTL reaches zero, the
packet is dropped. The TTL can be set by calling
<a href="gnet-udp.html#gnet-udp-socket-get-ttl"><code class="function">gnet_udp_socket_get_ttl()</code></a>. The default value is sufficient for most
applications.
</p>
</div>
<div class="refsect1" lang="en">
<a name="id351158"></a><h2>Details</h2>
<div class="refsect2" lang="en">
<a name="id351168"></a><h3>
<a name="GUdpSocket"></a>GUdpSocket</h3>
<a class="indexterm" name="id351180"></a><pre class="programlisting">typedef struct _GUdpSocket GUdpSocket;</pre>
<p>
A <a href="gnet-udp.html#GUdpSocket"><span class="type">GUdpSocket</span></a> structure represents a UDP socket. The
implementation is hidden.</p>
<p>
</p>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id351207"></a><h3>
<a name="gnet-udp-socket-new"></a>gnet_udp_socket_new ()</h3>
<a class="indexterm" name="id351219"></a><pre class="programlisting"><a href="gnet-udp.html#GUdpSocket">GUdpSocket</a>* gnet_udp_socket_new (void);</pre>
<p>
Creates a <a href="gnet-udp.html#GUdpSocket"><span class="type">GUdpSocket</span></a> bound to all interfaces and an arbitrary
port.</p>
<p>
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody><tr>
<td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td>
<td> a new <a href="gnet-udp.html#GUdpSocket"><span class="type">GUdpSocket</span></a>; NULL on error.
</td>
</tr></tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id351274"></a><h3>
<a name="gnet-udp-socket-new-with-port"></a>gnet_udp_socket_new_with_port ()</h3>
<a class="indexterm" name="id351287"></a><pre class="programlisting"><a href="gnet-udp.html#GUdpSocket">GUdpSocket</a>* gnet_udp_socket_new_with_port (gint port);</pre>
<p>
Creates a <a href="gnet-udp.html#GUdpSocket"><span class="type">GUdpSocket</span></a> bound to all interfaces and port <em class="parameter"><code>port</code></em>. If
<em class="parameter"><code>port</code></em> is 0, an arbitrary port will be used.</p>
<p>
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><span class="term"><em class="parameter"><code>port</code></em> :</span></td>
<td> port to bind to (0 for an arbitrary port)
</td>
</tr>
<tr>
<td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td>
<td> a new <a href="gnet-udp.html#GUdpSocket"><span class="type">GUdpSocket</span></a>; NULL on error.
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id351375"></a><h3>
<a name="gnet-udp-socket-new-full"></a>gnet_udp_socket_new_full ()</h3>
<a class="indexterm" name="id351387"></a><pre class="programlisting"><a href="gnet-udp.html#GUdpSocket">GUdpSocket</a>* gnet_udp_socket_new_full (const <a href="gnet-inetaddr.html#GInetAddr">GInetAddr</a> *iface,
gint port);</pre>
<p>
Creates a <a href="gnet-udp.html#GUdpSocket"><span class="type">GUdpSocket</span></a> bound to interface <em class="parameter"><code>iface</code></em> and port <em class="parameter"><code>port</code></em>.
If <em class="parameter"><code>iface</code></em> is NULL, all interfaces will be used. If <em class="parameter"><code>port</code></em> is 0, an
arbitrary port will be used.</p>
<p>
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><span class="term"><em class="parameter"><code>iface</code></em> :</span></td>
<td> interface to bind to (NULL for all interfaces)
</td>
</tr>
<tr>
<td><span class="term"><em class="parameter"><code>port</code></em> :</span></td>
<td> port to bind to (0 for an arbitrary port)
</td>
</tr>
<tr>
<td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td>
<td> a new <a href="gnet-udp.html#GUdpSocket"><span class="type">GUdpSocket</span></a>; NULL on error.
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id351509"></a><h3>
<a name="gnet-udp-socket-delete"></a>gnet_udp_socket_delete ()</h3>
<a class="indexterm" name="id351522"></a><pre class="programlisting">void gnet_udp_socket_delete (<a href="gnet-udp.html#GUdpSocket">GUdpSocket</a> *socket);</pre>
<p>
Deletes a <a href="gnet-udp.html#GUdpSocket"><span class="type">GUdpSocket</span></a>. Does nothing if <em class="parameter"><code>socket</code></em> is NULL.</p>
<p>
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody><tr>
<td><span class="term"><em class="parameter"><code>socket</code></em> :</span></td>
<td> a <a href="gnet-udp.html#GUdpSocket"><span class="type">GUdpSocket</span></a>, or NULL
</td>
</tr></tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id351592"></a><h3>
<a name="gnet-udp-socket-ref"></a>gnet_udp_socket_ref ()</h3>
<a class="indexterm" name="id351604"></a><pre class="programlisting">void gnet_udp_socket_ref (<a href="gnet-udp.html#GUdpSocket">GUdpSocket</a> *socket);</pre>
<p>
Adds a reference to a <a href="gnet-udp.html#GUdpSocket"><span class="type">GUdpSocket</span></a>.</p>
<p>
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody><tr>
<td><span class="term"><em class="parameter"><code>socket</code></em> :</span></td>
<td> <a href="gnet-udp.html#GUdpSocket"><span class="type">GUdpSocket</span></a> to reference
</td>
</tr></tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id351669"></a><h3>
<a name="gnet-udp-socket-unref"></a>gnet_udp_socket_unref ()</h3>
<a class="indexterm" name="id351682"></a><pre class="programlisting">void gnet_udp_socket_unref (<a href="gnet-udp.html#GUdpSocket">GUdpSocket</a> *socket);</pre>
<p>
Removes a reference from a <span class="type">GUdpScoket</span>. A <a href="gnet-udp.html#GUdpSocket"><span class="type">GUdpSocket</span></a> is deleted
when the reference count reaches 0.</p>
<p>
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody><tr>
<td><span class="term"><em class="parameter"><code>socket</code></em> :</span></td>
<td> a <a href="gnet-udp.html#GUdpSocket"><span class="type">GUdpSocket</span></a>
</td>
</tr></tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id351756"></a><h3>
<a name="gnet-udp-socket-send"></a>gnet_udp_socket_send ()</h3>
<a class="indexterm" name="id351768"></a><pre class="programlisting">gint gnet_udp_socket_send (<a href="gnet-udp.html#GUdpSocket">GUdpSocket</a> *socket,
const gchar *buffer,
gint length,
const <a href="gnet-inetaddr.html#GInetAddr">GInetAddr</a> *dst);</pre>
<p>
Sends data to a host using a <a href="gnet-udp.html#GUdpSocket"><span class="type">GUdpSocket</span></a>.</p>
<p>
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><span class="term"><em class="parameter"><code>socket</code></em> :</span></td>
<td> a <a href="gnet-udp.html#GUdpSocket"><span class="type">GUdpSocket</span></a>
</td>
</tr>
<tr>
<td><span class="term"><em class="parameter"><code>buffer</code></em> :</span></td>
<td> buffer to send
</td>
</tr>
<tr>
<td><span class="term"><em class="parameter"><code>length</code></em> :</span></td>
<td> length of <em class="parameter"><code>buffer</code></em>
</td>
</tr>
<tr>
<td><span class="term"><em class="parameter"><code>dst</code></em> :</span></td>
<td> destination address
</td>
</tr>
<tr>
<td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td>
<td> 0 if successful; something else on error.
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id351912"></a><h3>
<a name="gnet-udp-socket-receive"></a>gnet_udp_socket_receive ()</h3>
<a class="indexterm" name="id351924"></a><pre class="programlisting">gint gnet_udp_socket_receive (<a href="gnet-udp.html#GUdpSocket">GUdpSocket</a> *socket,
gchar *buffer,
gint length,
<a href="gnet-inetaddr.html#GInetAddr">GInetAddr</a> **src);</pre>
<p>
Receives data using a <a href="gnet-udp.html#GUdpSocket"><span class="type">GUdpSocket</span></a>. If <em class="parameter"><code>src</code></em> is set, the source
address is stored in the location <em class="parameter"><code>src</code></em> points to. The address is
caller owned.</p>
<p>
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><span class="term"><em class="parameter"><code>socket</code></em> :</span></td>
<td> a <a href="gnet-udp.html#GUdpSocket"><span class="type">GUdpSocket</span></a>
</td>
</tr>
<tr>
<td><span class="term"><em class="parameter"><code>buffer</code></em> :</span></td>
<td> buffer to write to
</td>
</tr>
<tr>
<td><span class="term"><em class="parameter"><code>length</code></em> :</span></td>
<td> length of <em class="parameter"><code>buffer</code></em>
</td>
</tr>
<tr>
<td><span class="term"><em class="parameter"><code>src</code></em> :</span></td>
<td> pointer to source address (optional)
</td>
</tr>
<tr>
<td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td>
<td> the number of bytes received, -1 on error.
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id352081"></a><h3>
<a name="gnet-udp-socket-has-packet"></a>gnet_udp_socket_has_packet ()</h3>
<a class="indexterm" name="id352093"></a><pre class="programlisting">gboolean gnet_udp_socket_has_packet (const <a href="gnet-udp.html#GUdpSocket">GUdpSocket</a> *socket);</pre>
<p>
Tests if a <a href="gnet-udp.html#GUdpSocket"><span class="type">GUdpSocket</span></a> has a packet waiting to be received.</p>
<p>
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><span class="term"><em class="parameter"><code>socket</code></em> :</span></td>
<td> a <a href="gnet-udp.html#GUdpSocket"><span class="type">GUdpSocket</span></a>
</td>
</tr>
<tr>
<td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td>
<td> TRUE if there is packet waiting, FALSE otherwise.
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id352169"></a><h3>
<a name="gnet-udp-socket-get-io-channel"></a>gnet_udp_socket_get_io_channel ()</h3>
<a class="indexterm" name="id352182"></a><pre class="programlisting">GIOChannel* gnet_udp_socket_get_io_channel (<a href="gnet-udp.html#GUdpSocket">GUdpSocket</a> *socket);</pre>
<p>
Gets the <span class="type">GIOChannel</span> of a <a href="gnet-udp.html#GUdpSocket"><span class="type">GUdpSocket</span></a>.
</p>
<p>
Use the channel with <code class="function">g_io_add_watch()</code> to check if the socket is
readable or writable. If the channel is readable, call
<a href="gnet-udp.html#gnet-udp-socket-receive"><code class="function">gnet_udp_socket_receive()</code></a> to receive a packet. If the channel is
writable, call <a href="gnet-udp.html#gnet-udp-socket-send"><code class="function">gnet_udp_socket_send()</code></a> to send a packet. This is
not a normal giochannel - do not read from or write to it.
</p>
<p>
Every <a href="gnet-udp.html#GUdpSocket"><span class="type">GUdpSocket</span></a> has one and only one <span class="type">GIOChannel</span>. If you ref
the channel, then you must unref it eventually. Do not close the
channel. The channel is closed by GNet when the socket is
deleted.
</p>
<p>
Before deleting the UDP socket, make sure to remove any watches you have
added with <code class="function">g_io_add_watch()</code> again with <code class="function">g_source_remove()</code> using the integer
id returned by <code class="function">g_io_add_watch()</code>. You may find your program stuck in a busy
loop at 100% CPU utilisation if you forget to do this.</p>
<p>
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><span class="term"><em class="parameter"><code>socket</code></em> :</span></td>
<td> a <a href="gnet-udp.html#GUdpSocket"><span class="type">GUdpSocket</span></a>
</td>
</tr>
<tr>
<td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td>
<td> a <span class="type">GIOChannel</span>.
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id352365"></a><h3>
<a name="gnet-udp-socket-get-local-inetaddr"></a>gnet_udp_socket_get_local_inetaddr ()</h3>
<a class="indexterm" name="id352378"></a><pre class="programlisting"><a href="gnet-inetaddr.html#GInetAddr">GInetAddr</a>* gnet_udp_socket_get_local_inetaddr (const <a href="gnet-udp.html#GUdpSocket">GUdpSocket</a> *socket);</pre>
<p>
Gets the local host's address from a <a href="gnet-udp.html#GUdpSocket"><span class="type">GUdpSocket</span></a>.</p>
<p>
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><span class="term"><em class="parameter"><code>socket</code></em> :</span></td>
<td> a <a href="gnet-udp.html#GUdpSocket"><span class="type">GUdpSocket</span></a>
</td>
</tr>
<tr>
<td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td>
<td> a <a href="gnet-inetaddr.html#GInetAddr"><span class="type">GInetAddr</span></a>.
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id352461"></a><h3>
<a name="gnet-udp-socket-get-ttl"></a>gnet_udp_socket_get_ttl ()</h3>
<a class="indexterm" name="id352473"></a><pre class="programlisting">gint gnet_udp_socket_get_ttl (const <a href="gnet-udp.html#GUdpSocket">GUdpSocket</a> *socket);</pre>
<p>
Gets the time-to-live (TTL) default of a <a href="gnet-udp.html#GUdpSocket"><span class="type">GUdpSocket</span></a>. All UDP
packets have a TTL field. This field is decremented by a router
before it forwards the packet. If the TTL reaches zero, the
packet is discarded. The default value is sufficient for most
applications.</p>
<p>
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><span class="term"><em class="parameter"><code>socket</code></em> :</span></td>
<td> a <a href="gnet-udp.html#GUdpSocket"><span class="type">GUdpSocket</span></a>
</td>
</tr>
<tr>
<td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td>
<td> the TTL (an integer between 0 and 255), -1 if the kernel
default is being used, or an integer less than -1 on error.
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id352551"></a><h3>
<a name="gnet-udp-socket-set-ttl"></a>gnet_udp_socket_set_ttl ()</h3>
<a class="indexterm" name="id352563"></a><pre class="programlisting">gint gnet_udp_socket_set_ttl (<a href="gnet-udp.html#GUdpSocket">GUdpSocket</a> *socket,
gint ttl);</pre>
<p>
Sets the time-to-live (TTL) default of a <a href="gnet-udp.html#GUdpSocket"><span class="type">GUdpSocket</span></a>. Set the TTL
to -1 to use the kernel default. The default value is sufficient
for most applications.</p>
<p>
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><span class="term"><em class="parameter"><code>socket</code></em> :</span></td>
<td> a <a href="gnet-udp.html#GUdpSocket"><span class="type">GUdpSocket</span></a>
</td>
</tr>
<tr>
<td><span class="term"><em class="parameter"><code>ttl</code></em> :</span></td>
<td> value to set TTL to
</td>
</tr>
<tr>
<td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td>
<td> 0 if successful.
</td>
</tr>
</tbody>
</table></div>
</div>
</div>
</div>
</body>
</html>
|