|
From: Orivej D. <or...@gm...> - 2014-09-18 21:21:36
|
> Abstract Unix socket is a socket namespace supported by Linux and > described in unix(7). > > Does SBCL have support for it? Yes, it has. Sockets are documented in the manual http://sbcl.org/manual/index.html, and section 14.5 describes LOCAL-SOCKET class. For example, (use-package :sb-bsd-sockets) (defparameter *socket-path* "/tmp/socket") (when (probe-file *socket-path*) (delete-file *socket-path*)) (defparameter s1 (make-instance 'local-socket :type :stream)) (socket-bind s1 *socket-path*) (socket-listen s1 0) (defparameter s2 (make-instance 'local-socket :type :stream)) (socket-connect s2 *socket-path*) (socket-send s2 "hello" nil) (defparameter s3 (socket-accept s1)) (socket-receive s3 nil 10) Alternatively, IOLIB also supports local sockets under SBCL: (use-package :iolib.sockets) (defparameter *socket-path* "/tmp/socket") (when (probe-file *socket-path*) (delete-file *socket-path*)) (defparameter s1 (make-socket :address-family :local :connect :passive :local-filename *socket-path*)) (listen-on s1) (defparameter s2 (make-socket :address-family :local :remote-filename *socket-path*)) (send-to s2 (sb-ext:string-to-octets "hello")) (defparameter s3 (accept-connection s1)) (receive-from s1 :size 10) |