1 ;;; -*- Mode: LISP; Syntax: COMMON-LISP; Package: CL-USER; Base: 10 -*-
2 ;;; $Header: /usr/local/cvsrep/hunchentoot/server.lisp,v 1.43 2008/04/09 08:17:48 edi Exp $
4 ;;; Copyright (c) 2004-2009, Dr. Edmund Weitz. All rights reserved.
6 ;;; Redistribution and use in source and binary forms, with or without
7 ;;; modification, are permitted provided that the following conditions
10 ;;; * Redistributions of source code must retain the above copyright
11 ;;; notice, this list of conditions and the following disclaimer.
13 ;;; * Redistributions in binary form must reproduce the above
14 ;;; copyright notice, this list of conditions and the following
15 ;;; disclaimer in the documentation and/or other materials
16 ;;; provided with the distribution.
18 ;;; THIS SOFTWARE IS PROVIDED BY THE AUTHOR 'AS IS' AND ANY EXPRESSED
19 ;;; OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 ;;; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 ;;; ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
22 ;;; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 ;;; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
24 ;;; GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 ;;; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26 ;;; WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27 ;;; NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 ;;; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 (in-package :hunchentoot
)
32 ;;; system specific implementation of the function that sets up
33 ;;; connection timeouts
35 (defun set-timeouts (usocket read-timeout write-timeout
)
36 "Sets up timeouts on the given USOCKET object. READ-TIMEOUT is the
37 read timeout period, WRITE-TIMEOUT is the write timeout, specified in
38 seconds. The timeouts can either be implemented using the low-level
39 socket options SO_RCVTIMEO and SO_SNDTIMEO or some other,
40 implementation specific mechanism. On platforms that do not support
41 separate read and write timeouts, both must be equal or an error will
42 be signaled. READ-TIMEOUT and WRITE-TIMEOUT may be NIL, which means
43 that the corresponding socket timeout value will not be set."
44 (declare (ignorable usocket read-timeout write-timeout
))
46 ;; add other Lisps here if necessary
47 (unless (eql read-timeout write-timeout
)
48 (parameter-error "Read and write timeouts for socket must be equal."))
51 (socket:socket-options
(usocket:socket usocket
) :SO-RCVTIMEO read-timeout
))
54 (socket:socket-options
(usocket:socket usocket
) :SO-SNDTIMEO write-timeout
))
57 (setf (ccl:stream-input-timeout
(usocket:socket usocket
))
61 (setf (ccl:stream-output-timeout
(usocket:socket usocket
))
64 (setf (sb-impl::fd-stream-timeout
(usocket:socket-stream usocket
))
65 (coerce read-timeout
'single-float
))
67 (setf (lisp::fd-stream-timeout
(usocket:socket-stream usocket
))
68 (coerce read-timeout
'integer
))
69 #-
(or :clisp
:allegro
:openmcl
:sbcl
:lispworks
:cmu
)
70 (not-implemented 'set-timeouts
))