local
Networking > Address specifiers
Next:<local> ( path -- addrspec )


Vocabulary
io.sockets

Class description
Local address specifier for Unix domain sockets on Unix systems. The path slot holds the path name of the socket. New instances are created by calling <local>.

Examples
"/tmp/.X11-unix/0" <local>


Definition
USING: strings ;

IN: io.sockets

TUPLE: local { path string read-only initial: "" } ;


Methods
USING: arrays io.servers.private io.sockets ;

M: local >insecure 1array ;


USING: io.servers.private io.sockets ;

M: local connect-addr ;


USING: classes.struct io.sockets io.sockets.private kernel
unix.ffi ;

M: local empty-sockaddr drop sockaddr-un <struct> ;


USING: accessors alien.strings classes.struct io.encodings.utf8
io.pathnames io.sockets io.sockets.private kernel math
sequences unix.ffi ;

M: local make-sockaddr
path>> absolute-path dup length 1 + max-un-path >
[ "Path too long" throw ] when
sockaddr-un <struct> AF_UNIX >>family
swap utf8 string>alien >>path ;


USING: accessors alien.strings io.encodings.utf8 io.sockets
io.sockets.private kernel ;

M: local parse-sockaddr drop path>> utf8 alien>string <local> ;


USING: accessors io.sockets present sequences ;

M: local present path>> "Unix domain socket: " prepend ;


USING: io.sockets io.sockets.private kernel ;

M: local protocol drop 0 ;


USING: io.sockets io.sockets.private kernel unix.ffi ;

M: local protocol-family drop PF_UNIX ;


USING: arrays io.sockets ;

M: local resolve-host 1array ;


USING: alien.c-types io.sockets io.sockets.private kernel
unix.ffi ;

M: local sockaddr-size drop sockaddr-un heap-size ;