source: project/wiki/tcp-server @ 8832

Last change on this file since 8832 was 8832, checked in by Alaric Snell-Pym, 12 years ago

Markup fixes

File size: 3.4 KB
Line 
1[[tags: egg]]
2
3== Introduction
4
5A generic multithreaded TCP server.
6
7== Example
8
9A simple time-of-day server:
10
11<example>
12<init>(require-extension tcp-server posix)</init>
13<expr>((make-tcp-server
14  (tcp-listen 6504)
15  (lambda ()
16    (write-line (seconds->string (current-seconds))) ) )
17 #t)</expr>
18</example>
19
20== Author
21
22[[felix winkelmann|Felix Winkelmann]]
23
24== License
25
26Copyright (c) 2004, Felix L. Winkelmann
27All rights reserved.
28
29Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following
30conditions are met:
31
32* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
33* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
34* Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
35
36THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
37OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
38AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
39CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
40CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
41SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
42THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
43OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
44POSSIBILITY OF SUCH DAMAGE.
45
46== Requirements
47
48None
49
50== Documentation
51<procedure>(make-tcp-server LISTENER THUNK [MAXREQUESTS])</procedure>
52
53Returns a procedure that, when invoked, will start the TCP server. {{LISTENER}} should be
54a {{tcp-listener}} objects as returned by {{tcp-listen}}. For every incoming request, a
55thread will be started and {{THUNK}} (a procedure of zero arguments) will be invoked, with
56the current input- and output-ports bound so that any I/O is done from/to the client connection.
57If the optional argument {{MAXREQUESTS}} is given, then it specifies an upper limit for
58currently executing requests. The returned server procedure accepts an optional argument that
59indicates whether some diagnostic messages for incoming requests should be written to the value
60of {{(current-error-port)}}. The optional argument may be a string (which will prefix each
61diagnostic message), or just {{#t}} (which results in a default prefix).
62
63<parameter>tcp-server-prepare-hard-close-procedure</parameter>
64<parameter>tcp-server-accept-connection-procedure</parameter>
65<parameter>tcp-server-get-addresses-procedure</parameter>
66
67Parameters containing primitive socket operations. Use these to parameterize the exact
68behaviour for closing abruptly, accepting connections and getting peer addresses (for example
69to use the [[openssl]] egg in combination with the generic server).
70The default values are {{tcp-abandon-port}}, {{tcp-accept}} and {{tcp-addresses}},
71respectively.
72
73== Version History
74
75* 1.2: Added parameterized socket-primitives (Contributed by Thomas Chust)
76* 1.1: The verbosity argument of the tcp-server procedure may be a string, now.
77* 1.0
Note: See TracBrowser for help on using the repository browser.