File: UDPSocket.html

package info (click to toggle)
libape 1.0.0-3
  • links: PTS
  • area: main
  • in suites: potato
  • size: 1,572 kB
  • ctags: 1,343
  • sloc: sh: 7,342; cpp: 3,418; makefile: 117
file content (137 lines) | stat: -rw-r--r-- 5,186 bytes parent folder | download
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
<HTML><HEAD><TITLE>UDPSocket Class</TITLE></HEAD>
<BODY bgcolor="#ffffff">

<H1>UDPSocket Class Reference</H1>
<p>
[<A HREF="index.html">APE Index</A>] [<A HREF="hier.html">APE Hierarchy</A>]
[<A HREF="header-list.html">Headers</A>]
</p>
<HR>
<P>Unreliable Datagram Protocol sockets.   <a href="#short">More...</a></P>
<P>
<code>
	#include &lt;<a href="socket-h.html">socket.h</a>&gt;
</code>

</P>

<P>
Inherits: <a href="Socket.html">Socket</a>
<P>
<H2>Public Members</H2>
<UL>
<LI> <b><a href="#ref0">UDPSocket</a></b> (void) 
</LI>
<LI> <b><a href="#ref1">UDPSocket</a></b> (InetAddress &amp;bind, short port) 
</LI>
<LI> <b><a href="#ref2">UDPSocket</a></b> (InetHostAddress &amp;host, short port) 
</LI>
<LI> <b><a href="#ref3">UDPSocket</a></b> (BroadcastAddress &amp;cast, short port) 
</LI>
<LI>int <b><a href="#ref4">Write</a></b> (InetHostAddress &amp;host, short port, void *addr, size_t len) 
</LI>
<LI>friend inline int <b><a name="ref5">write</a></b> (UDPSocket &amp;s, InetHostAddress &amp;host, short port, void *addr, size_t len) 
</LI>
</UL>
<HR>
<H2><a name="short">Detailed Description</a></H2>
<P>

 UDP sockets implement the TCP SOCK_DGRAM UDP protocol.  They can be
 used to pass unverified messages between hosts, or to broadcast a
 specific message to an entire subnet.  Please note that Streaming of
 realtime data commonly use UDPSimplex or UDPDuplex rather than
 UDPSocket.
 

</P><HR>
<H3><b> <a name="ref0"></a><a name="UDPSocket">UDPSocket</a>(void)  </b><code>[public]</code></H3>
<p>Create an unbound UDP socket, mostly for internal use.
</p>
<H3><b> <a name="ref1"></a><a name="UDPSocket">UDPSocket</a>(<a href="InetAddress.html">InetAddress</a> &amp;bind, short port)  </b><code>[public]</code></H3>
<p>Create a UDP socket and bind it to a specific interface
and port address so that other UDP sockets on remote
machines (or the same host) may find and send UDP messages
to it.  On failure to bind, an exception is thrown.
</p><p>
</p>
<dl><dt><b>Parameters</b>:<dd>
<table width="100%" border="0">
<tr><td align="left" valign="top">
port</td><td align="left" valign="top">
number to bind this socket to.</td></tr>
<tr><td align="left" valign="top">
bind</td><td align="left" valign="top">
address to bind this socket to.</td></tr>
</table>
</dl>
<H3><b> <a name="ref2"></a><a name="UDPSocket">UDPSocket</a>(<a href="InetHostAddress.html">InetHostAddress</a> &amp;host, short port)  </b><code>[public]</code></H3>
<p>Create a UDP socket that is connected to another UDP socket.
While a UDP socket "connection" has no tangible resource unlike
with TCP, it does prevent the socket from accepting UDP packets
from any socket other than the one that it is connected to.
</p><p>
</p>
<dl><dt><b>Parameters</b>:<dd>
<table width="100%" border="0">
<tr><td align="left" valign="top">
port</td><td align="left" valign="top">
number to connect the local socket to.</td></tr>
<tr><td align="left" valign="top">
host</td><td align="left" valign="top">
address to connect the local socket to.</td></tr>
</table>
</dl>
<H3><b> <a name="ref3"></a><a name="UDPSocket">UDPSocket</a>(<a href="BroadcastAddress.html">BroadcastAddress</a> &amp;cast, short port)  </b><code>[public]</code></H3>
<p>Bind a UDP socket for use in sending subnet broadcast messages.
This enables the SO_BROADCAST attribute of the socket.
</p><p>
</p>
<dl><dt><b>Parameters</b>:<dd>
<table width="100%" border="0">
<tr><td align="left" valign="top">
cast</td><td align="left" valign="top">
address of subnet to broadcast messages on.</td></tr>
<tr><td align="left" valign="top">
port</td><td align="left" valign="top">
number to receive messages from other broadcasters.</td></tr>
</table>
</dl>
<H3><b>int <a name="ref4"></a><a name="Write">Write</a>(<a href="InetHostAddress.html">InetHostAddress</a> &amp;host, short port, void *addr, size_t len)  </b><code>[public]</code></H3>
<p>Write a UDP message of arbitrary bytes.  Each write genorates a
unique UDP message of the specified length, rather than simply
writing data to a stream.  Hence, if one is writing a message
composed of a header and data segment, all of which are meant to
be sent as one UDP message, then one must do so in a single
Write operation or through the use of writev.
</p><p>
</p>
<dl><dt><b>Parameters</b>:<dd>
<table width="100%" border="0">
<tr><td align="left" valign="top">
addr</td><td align="left" valign="top">
pointer to UDP message data.</td></tr>
<tr><td align="left" valign="top">
port</td><td align="left" valign="top">
number of destination socket.</td></tr>
<tr><td align="left" valign="top">
host</td><td align="left" valign="top">
internet address of destination socket.</td></tr>
<tr><td align="left" valign="top">
len</td><td align="left" valign="top">
number of bytes in UDP message.</td></tr>
</table>
</dl>
<dl><dt><b>Returns</b>:<dd>
number of bytes sent on success, -1 on error.</dl>
<HR>
<TABLE WIDTH="100%"><TR><TD ALIGN="left" VALIGN="top">

<UL><LI><I>Author</I>: David Sugar &lt;dyfet@ostel.com&gt;. </LI>
<LI>Documentation generated by dyfet@home.sys on Thu Dec 16 09:54:26 EST 1999
</LI>
</UL></TD><TD ALIGN="RIGHT" VALIGN="TOP">
<b>K</b><i>doc</i>
</TD>
</TR></TABLE></BODY></HTML>