source: project/wiki/tcp-server @ 8840

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

Claimed tagged-begin to wikify

Semantically meaningless touch of tcp-server and tcc to cause regeneration of examples on commit hook

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