source: project/udp/udp.html @ 3

Last change on this file since 3 was 3, checked in by felix winkelmann, 15 years ago

udp/test-infrastructure changes; added futures

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