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
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
22 ;; not sure if these are really good names or not
31 ;; all socket options are also exported, by code in
36 ;; other errno-based socket errors are exported by code in
42 (:use "COMMON-LISP" "SB-BSD-SOCKETS-INTERNAL")
43 (:import-from "SB-INT" "UNSUPPORTED-OPERATOR" "FEATUREP")
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.
48 We represent sockets as CLOS objects, and rename a lot of methods and
49 arguments to fit Lisp style more closely."))
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.
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.
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")))
63 (pushnew :sb-bsd-sockets-addrinfo *features*)))