1 (defpackage "SB-BSD-SOCKETS-INTERNAL"
4 (:shadowing-import-from "SB-KERNEL" with-array-data)
5 (:use "COMMON-LISP" "SB-ALIEN" "SB-EXT"))
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 socket-recv
12 socket-name socket-peername socket-listen
13 socket-close socket-file-descriptor
14 socket-family socket-protocol socket-open-p
15 socket-type socket-make-stream get-protocol-by-name
17 get-host-by-name get-host-by-address
19 host-ent-addresses host-ent-address
20 host-ent-aliases host-ent-name
23 ;; not sure if these are really good names or not
32 ;; all socket options are also exported, by code in
37 ;; other errno-based socket errors are exported by code in
43 (:use "COMMON-LISP" "SB-BSD-SOCKETS-INTERNAL")
44 (:import-from "SB-INT" "UNSUPPORTED-OPERATOR" "FEATUREP")
46 "A thinly-disguised BSD socket API for SBCL. Ideas stolen from the BSD
47 socket API for C and Graham Barr's IO::Socket classes for Perl.
49 We represent sockets as CLOS objects, and rename a lot of methods and
50 arguments to fit Lisp style more closely."))
52 ;;; gethostbyname/gethostbyaddr are generally not thread safe. POSIX
53 ;;; 1003.1-2003 defines an alternative API, which is specified in the
54 ;;; RFC to be thread-safe. If it seems to be available, use it.
56 ;;; Unfortunately the manual page claims that these functions are not
57 ;;; thread-safe on OS X, but they probably can't be any worse than
58 ;;; gethostbyname and gethostbyaddr.
60 ;;; CLH: getaddrinfo seems to be broken is broken on x86-64/darwin
62 (let ((addr (sb-alien::find-dynamic-foreign-symbol-address "getaddrinfo")))
64 (pushnew :sb-bsd-sockets-addrinfo *features*)))