Add SOCKET-SHUTDOWN in contrib/sb-bsd-sockets
[sbcl.git] / contrib / sb-bsd-sockets / defpackage.lisp
1 (defpackage "SB-BSD-SOCKETS-INTERNAL"
2   (:nicknames "SOCKINT")
3   (:shadow close listen)
4   (:shadowing-import-from "SB-KERNEL" with-array-data)
5   (:use "COMMON-LISP" "SB-ALIEN" "SB-EXT"))
6
7 (defpackage "SB-BSD-SOCKETS"
8   (:export socket local-socket local-abstract-socket inet-socket
9            make-local-socket make-inet-socket
10            socket-bind socket-accept socket-connect
11            socket-send socket-receive
12            socket-name socket-peername socket-listen
13            socket-close socket-shutdown socket-file-descriptor
14            socket-family socket-protocol socket-open-p
15            socket-type socket-make-stream get-protocol-by-name
16
17            get-host-by-name get-host-by-address
18            host-ent
19            host-ent-addresses host-ent-address
20            host-ent-aliases host-ent-name
21            name-service-error
22            ;; not sure if these are really good names or not
23            netdb-internal-error
24            netdb-success-error
25            host-not-found-error
26            try-again-error
27            no-recovery-error
28
29            unknown-protocol
30
31            ;; all socket options are also exported, by code in
32            ;; sockopt.lisp
33
34            socket-error
35
36            ;; other errno-based socket errors are exported by code in
37            ;; sockets.lisp
38
39            make-inet-address
40
41            non-blocking-mode)
42   (:use "COMMON-LISP" "SB-BSD-SOCKETS-INTERNAL")
43   (:import-from "SB-INT" "UNSUPPORTED-OPERATOR" "FEATUREP")
44   (:documentation
45    "A thinly-disguised BSD socket API for SBCL.  Ideas stolen from the BSD
46 socket API for C and Graham Barr's IO::Socket classes for Perl.
47
48 We represent sockets as CLOS objects, and rename a lot of methods and
49 arguments to fit Lisp style more closely."))
50
51 ;;; gethostbyname/gethostbyaddr are generally not thread safe. POSIX
52 ;;; 1003.1-2003 defines an alternative API, which is specified in the
53 ;;; RFC to be thread-safe. If it seems to be available, use it.
54 ;;;
55 ;;; Unfortunately the manual page claims that these functions are not
56 ;;; thread-safe on OS X, but they probably can't be any worse than
57 ;;; gethostbyname and gethostbyaddr.
58 ;;;
59 ;;; CLH: getaddrinfo seems to be broken is broken on x86-64/darwin
60 #-(or win32 (and x86-64 darwin))
61 (let ((addr (sb-alien::find-dynamic-foreign-symbol-address "getaddrinfo")))
62   (when addr
63     (pushnew :sb-bsd-sockets-addrinfo *features*)))