source: project/nondescript/sockets/sockets.html @ 35339

Last change on this file since 35339 was 2448, checked in by elf, 14 years ago

updated. do not use.

File size: 6.2 KB
Line 
1<html>
2<head><title>Eggs Unlimited - udp</title></head>
3<body>
4<font face="Arial, Helvetica">
5
6<center><img src="egg.jpg"></center>
7<center><a href="index.html">back</a></center>
8
9<h2>udp</h2>
10
11<h3>Description:</h3>
12
13<p> An interface to User Datagram Protocol sockets.
14
15<h3>Author:</h3>
16<p> Category 5, with several enhancements by Daishi Kato
17
18<h3>Version:</h3>
19<ul>
20<li>1.12
21Didn't include signal.h on UNIX [felix]
22<li>1.11
23More Win32 support [Daishi Kato]
24<li>1.10
25Multicast support [Daishi Kato]
26<li>1.9
27Win32 socket-header fun
28<li>1.8
29Hopefully succeeded in actually fixing that cygwin problem (which wasn't a cygwin problem after all, but a broken
30declaration of <code>##net#recvfrom</code>)
31<li>1.7
32Fixed cygwin problem [thanks to Daishi Kato]
33<li>1.6
34#includes ws2tcpip.h instead of winsock2.h [Thanks to Graham Fawcett]
35<li>1.5
36Small fix (uses srfi-18 unit, now)
37<li>1.4
38<code>udp-bound-port</code> [Contributed by Daishi Kato]
39<li>1.3
40Yet another bugfix for better Windows support by Daishi Kato
41<li>1.2
42Daishi Kato fixed several bugs
43<li>1.1
44</ul>
45
46<h3>Usage:</h3> 
47<p> <tt>(require-extension udp)</tt>
48
49<h3>Download:</h3>
50<p> <a href="http://www.call-with-current-continuation.org/eggs/udp.egg">udp.egg</a>
51
52<h3>Documentation:</h3>
53<dl>
54
55<dt><pre><b>[procedure] (udp-open-socket)</b></pre>
56<dd>
57  Returns a new UDP socket object.
58</dd>
59
60<dt><pre><b>[procedure] (udp-open-socket*)</b></pre>
61<dd>
62  Returns a new nonblocking UDP socket object.
63</dd>
64
65<dt><pre><b>[procedure] (udp-bind! SOCKET HOST PORT)</b></pre>
66<dd>
67  Binds a UDP socket to an address and port as specified by HOST and PORT.
68  HOST may be a string consisting of an IP address or hostname, or
69  <tt>#f</tt>, in which case INADDR_ANY is used.  If PORT is 0, a port will be
70  allocated by the system automatically.
71</dd>
72
73<dt><pre><b>[procedure] (udp-connect! SOCKET HOST PORT)</b></pre>
74<dd>
75  Connect a socket.  In the case of UDP this does nothing more than
76  associate a peer address with the socket in the kernel for use
77  with later calls to send(2).  UDP is a connectionless protocol.
78</dd>
79
80<dt><pre><b>[procedure] (udp-send SOCKET STRING)</b></pre>
81<dd>
82  Send the bytes in STRING through SOCKET to its peer, as specified
83  with a previous call to <b>udp-connect!</b>.  If the socket is not
84  connected, the system will return an error.
85</dd>
86
87<dt><pre><b>[procedure] (udp-sendto SOCKET HOST PORT STRING)</b></pre>
88<dd>
89  Send the bytes in STRING through SOCKET to PORT on HOST.
90</dd>
91
92<dt><pre><b>[procedure] (udp-recv SOCKET LENGTH)</b></pre>
93<dd>
94  Receive a packet and store the data in string of size <code>LENGTH</code>.  Returns two values:
95  the number <tt>n</tt> of bytes received and the string consisting the message.
96</dd>
97
98<dt><pre><b>[procedure] (udp-recvfrom SOCKET LENGTH)</b></pre>
99<dd>
100  Same as <b>udp-recv</b> except that two additional values are returned:
101  the host string and port number from which the packet was received.
102</dd>
103
104<dt><pre><b>[procedure] (udp-close-socket SOCKET)</b></pre>
105<dd>
106  Close a socket.
107</dd>
108
109<dt><pre><b>[procedure] (udp-socket? THING)</b></pre>
110<dd>
111  Test whether THING is a UDP socket.
112</dd>
113
114<dt><pre><b>[procedure] (udp-bound? SOCKET)</b></pre>
115<dd>
116  Test whether a UDP socket is bound to a local address and port.
117</dd>
118
119<dt><pre><b>[procedure] (udp-connected? SOCKET)</b></pre>
120<dd>
121  Test whether a peer address and port has been associated with a
122  UDP socket with a call to <b>udp-connect!</b>.
123</dd>
124
125<dt><pre><b>[procedure] (udp-bound-port SOCKET)</b></pre>
126<dd>Returns the port to which the socket is bound.
127</dd>
128
129<dt><pre><b>[procedure] (udp-set-multicast-interface SOCKET ADDRESS)</b></pre>
130<dd>Specify the ADDRESS of the interface to send a multicast packet.
131    This procedure might not be needed if there is only one network interface.
132</dd>
133
134<dt><pre><b>[procedure] (udp-join-multicast-group SOCKET ADDRESS GROUP [JOIN])</b></pre>
135<dd>Join a multicast GROUP with the interface of the ADDRESSS
136    which can be #f for INADDR_ANY. If the optional argument
137    JOIN is set and #f, the multicast group is dropped.
138</dd>
139
140</dl>
141
142<p><h3>Examples:</h3>
143<pre>
144  csi> (require 'udp)
145  ; loading /usr/local/lib/chicken/udp.so ...
146  csi> (define s (udp-open-socket))
147  csi> (udp-bind! s #f 0)
148  csi> (udp-connect! s "localhost" 13)  ; daytime service
149  csi> (udp-send s "\n")
150  csi> (receive (n data from-host from-port) (udp-recvfrom s 64)
151         (print* n " bytes from " from-host ":" from-port ": " data))
152  26 bytes from 127.0.0.1:13: Wed Dec 24 11:53:14 2003
153  csi> (udp-close-socket s)
154  csi>
155</pre>
156
157<h3>License:</h3>
158
159<pre>
160Copyright (c) 2004, Category 5
161All rights reserved.
162
163Redistribution and use in source and binary forms, with or without
164modification, are permitted provided that the following conditions are met:
165
166  Redistributions of source code must retain the above copyright notice,
167  this list of conditions and the following disclaimer. Redistributions in
168  binary form must reproduce the above copyright notice, this list of
169  conditions and the following disclaimer in the documentation and/or other
170  materials provided with the distribution. Neither the name of the author
171  nor the names of its contributors may be used to endorse or promote
172  products derived from this software without specific prior written
173  permission.
174
175THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
176AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
177IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
178ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
179LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
180CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
181SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
182INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
183CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
184ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
185POSSIBILITY OF SUCH DAMAGE.
186</pre>
187
188<hr><a href="index.html">back</a>
189
190</font>
191</body>
192</html>
Note: See TracBrowser for help on using the repository browser.