1.102 <GUnixSocketAddress>

Class: <GUnixSocketAddress>

It derives from <GSocketAddress>.

Support for UNIX-domain (also known as local) sockets, corresponding to struct sockaddr_un.

UNIX domain sockets are generally visible in the filesystem. However, some systems support abstract socket names which are not visible in the filesystem and not affected by the filesystem permissions, visibility, etc. Currently this is only supported under Linux. If you attempt to use abstract sockets on other systems, function calls may return not-supported errors. You can use unix-socket-address:abstract-names-supported? to see if abstract names are supported.

Since GLib 2.72, <GUnixSocketAddress> is available on all platforms. It requires underlying system support (such as Windows 10 with AF_UNIX) at run time.

Before GLib 2.72, <gio/gunixsocketaddress.h> belonged to the UNIX-specific GIO interfaces, thus you had to use the gio-unix-2.0.pc pkg-config file when using it. This is no longer necessary since GLib 2.72.

Fields

parent-instance

Properties

Property: unix-socket-address:abstract self

Whether or not this is an abstract address

Its value is a boolean.

It can only be set when the object is made, with #:abstract.

Property: unix-socket-address:address-type self

The type of Unix socket address.

Its value is a <GUnixSocketAddressType> (or, to set it, one of its symbols).

It can only be set when the object is made, with #:address-type.

Property: unix-socket-address:path self

Unix socket path.

Its value is a string, or #f.

It can only be set when the object is made, with #:path.

Property: unix-socket-address:path-as-array self

Unix socket path, as a byte array.

Its value is a <GByteArray>, or #f.

It can only be set when the object is made, with #:path-as-array.

Procedures

Procedure: unix-socket-address:abstract-names-supported? ⇒ %return

Checks if abstract UNIX domain socket names are supported.

%return

Returned: a boolean.

#t if supported, #f otherwise

Method: unix-socket-address:get-address-type self ⇒ %return
Method: get-address-type self ⇒ %return

Gets self’s type.

self

Passed: a <GUnixSocketAddress>.

a <GInetSocketAddress>

%return

Returned: a <GUnixSocketAddressType>.

a <GUnixSocketAddressType>

Method: unix-socket-address:get-is-abstract? self ⇒ %return
Method: get-is-abstract? self ⇒ %return

Tests if self is abstract.

self

Passed: a <GUnixSocketAddress>.

a <GInetSocketAddress>

%return

Returned: a boolean.

#t if the address is abstract, #f otherwise

Method: unix-socket-address:get-path self ⇒ %return
Method: get-path self ⇒ %return

Gets self’s path, or for abstract sockets the "name".

Guaranteed to be zero-terminated, but an abstract socket may contain embedded zeros, and thus you should use unix-socket-address:get-path-len to get the true length of this string.

self

Passed: a <GUnixSocketAddress>.

a <GInetSocketAddress>

%return

Returned: a string.

the path for self

Method: unix-socket-address:get-path-len self ⇒ %return
Method: get-path-len self ⇒ %return

Gets the length of self’s path.

For details, see unix-socket-address:get-path.

self

Passed: a <GUnixSocketAddress>.

a <GInetSocketAddress>

%return

Returned: an unsigned 64-bit integer.

the length of the path

Procedure: unix-socket-address:new path ⇒ %return

Creates a new <GUnixSocketAddress> for path.

To create abstract socket addresses, on systems that support that, use unix-socket-address:new-abstract.

path

Passed: a string.

the socket path

%return

Returned: a <GSocketAddress>.

a new <GUnixSocketAddress>

Procedure: unix-socket-address:new-abstract path ⇒ %return

Creates a new abstract-padded <GUnixSocketAddress> for path.

path

Passed: a s8vector, or a list or vector, each an 8-bit integer.

the abstract name

%return

Returned: a <GSocketAddress>.

a new <GUnixSocketAddress>

path-len

Not passed: guile-gi gives the length of path.

the length of path, or -1

Procedure: unix-socket-address:new-with-type path type ⇒ %return

Creates a new <GUnixSocketAddress> of type type with name path.

If type is path, this is equivalent to calling unix-socket-address:new.

If type is anonymous, path and path-len will be ignored.

If path-type is abstract, then path-len bytes of path will be copied to the socket’s path, and only those bytes will be considered part of the name. (If path-len is -1, then path is assumed to be NUL-terminated.) For example, if path was "test", then calling socket-address:get-native-size on the returned socket would return 7 (2 bytes of overhead, 1 byte for the abstract-socket indicator byte, and 4 bytes for the name "test").

If path-type is abstract-padded, then path-len bytes of path will be copied to the socket’s path, the rest of the path will be padded with 0 bytes, and the entire zero-padded buffer will be considered the name. (As above, if path-len is -1, then path is assumed to be NUL-terminated.) In this case, socket-address:get-native-size will always return the full size of a struct sockaddr_un, although unix-socket-address:get-path-len will still return just the length of path.

abstract is preferred over abstract-padded for new programs. Of course, when connecting to a server created by another process, you must use the appropriate type corresponding to how that process created its listening socket.

path

Passed: a s8vector, or a list or vector, each an 8-bit integer.

the name

type

Passed: a <GUnixSocketAddressType>, or one of its symbols.

a <GUnixSocketAddressType>

%return

Returned: a <GSocketAddress>.

a new <GUnixSocketAddress>

path-len

Not passed: guile-gi gives the length of path.

the length of path, or -1