source: project/udp/udp.html @ 1

Last change on this file since 1 was 1, checked in by azul, 14 years ago

Import everything.

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