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