Next: , Up: posix socket addresses   [Index]


4.15.1.1 Local addresses

Instances of struct sockaddr_un can be handled at the Scheme level as follows:

(import (vicare)
  (prefix (vicare posix) px.))

(define sockaddr
  (px.make-sockaddr_un "/tmp/the-unix-socket"))

(px.sockaddr_un.pathname/string sockaddr)
⇒ "/tmp/the-unix-socket"

care must be taken when handling such raw values.

Function: make-sockaddr_un pathname

Given a pathname representing the pathname of a local socket, build and return a bytevector holding the struct sockaddr_un representing it.

Function: sockaddr_un.pathname socket_address
Function: sockaddr_un.pathname/string socket_address

Given a bytevector socket_address, which must be the return value of a previous call to make-sockaddr_un, holding a struct sockaddr_un: sockaddr_un.pathname builds and returns a bytevector holding the corresponding socket pathname, sockaddr_un.pathname/string builds and returns a string holding the corresponding socket pathname. If the data in socket_address is invalid: an exception is raised.