Gio.UnixSocketAddress

g GObject.GInterface GObject.GInterface Gio.SocketConnectable Gio.SocketConnectable GObject.GInterface->Gio.SocketConnectable GObject.Object GObject.Object Gio.SocketAddress Gio.SocketAddress GObject.Object->Gio.SocketAddress Gio.UnixSocketAddress Gio.UnixSocketAddress Gio.SocketAddress->Gio.UnixSocketAddress Gio.SocketConnectable->Gio.SocketAddress

Subclasses:

None

Methods

Inherited:

Gio.SocketAddress (4), GObject.Object (37), Gio.SocketConnectable (3)

Structs:

GObject.ObjectClass (5)

class

abstract_names_supported ()

class

new (path)

class

new_abstract (path)

class

new_with_type (path, type)

get_address_type ()

get_is_abstract ()

get_path ()

get_path_len ()

Virtual Methods

Inherited:

Gio.SocketAddress (3), GObject.Object (7), Gio.SocketConnectable (3)

Properties

Inherited:

Gio.SocketAddress (1)

Name

Type

Flags

Short Description

abstract

bool

r/w/co

Whether or not this is an abstract address deprecated

address-type

Gio.UnixSocketAddressType

r/w/co

The type of UNIX socket address

path

str

r/w/co

UNIX socket path

path-as-array

GLib.ByteArray

r/w/co

UNIX socket path, as byte array

Signals

Inherited:

GObject.Object (1)

Fields

Inherited:

GObject.Object (1)

Name

Type

Access

Description

parent_instance

Gio.SocketAddress

r

Class Details

class Gio.UnixSocketAddress(**kwargs)
Bases:

Gio.SocketAddress

Abstract:

No

Structure:

Gio.UnixSocketAddressClass

Support for UNIX-domain (also known as local) sockets.

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 Gio.IOErrorEnum.NOT_SUPPORTED errors. You can use Gio.UnixSocketAddress.abstract_names_supported() to see if abstract names are supported.

Since GLib 2.72, Gio.UnixSocketAddress 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.

classmethod abstract_names_supported()[source]
Returns:

True if supported, False otherwise

Return type:

bool

Checks if abstract UNIX domain socket names are supported.

New in version 2.22.

classmethod new(path)[source]
Parameters:

path (str) – the socket path

Returns:

a new Gio.UnixSocketAddress

Return type:

Gio.SocketAddress

Creates a new Gio.UnixSocketAddress for path.

To create abstract socket addresses, on systems that support that, use Gio.UnixSocketAddress.new_abstract().

New in version 2.22.

classmethod new_abstract(path)[source]
Parameters:

path ([int]) – the abstract name

Returns:

a new Gio.UnixSocketAddress

Return type:

Gio.SocketAddress

Creates a new Gio.UnixSocketAddressType.ABSTRACT_PADDED Gio.UnixSocketAddress for path.

Deprecated since version ???: Use Gio.UnixSocketAddress.new_with_type().

classmethod new_with_type(path, type)[source]
Parameters:
Returns:

a new Gio.UnixSocketAddress

Return type:

Gio.SocketAddress

Creates a new Gio.UnixSocketAddress of type type with name path.

If type is Gio.UnixSocketAddressType.PATH, this is equivalent to calling Gio.UnixSocketAddress.new().

If type is Gio.UnixSocketAddressType.ANONYMOUS, path and path_len will be ignored.

If path_type is Gio.UnixSocketAddressType.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 Gio.SocketAddress.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 Gio.UnixSocketAddressType.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, Gio.SocketAddress.get_native_size() will always return the full size of a struct sockaddr_un, although Gio.UnixSocketAddress.get_path_len() will still return just the length of path.

Gio.UnixSocketAddressType.ABSTRACT is preferred over Gio.UnixSocketAddressType.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.

New in version 2.26.

get_address_type()[source]
Returns:

a Gio.UnixSocketAddressType

Return type:

Gio.UnixSocketAddressType

Gets self's type.

New in version 2.26.

get_is_abstract()[source]
Returns:

True if the address is abstract, False otherwise

Return type:

bool

Tests if self is abstract.

New in version 2.22.

Deprecated since version ???: Use Gio.UnixSocketAddress.get_address_type()

get_path()[source]
Returns:

the path for self

Return type:

str

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 Gio.UnixSocketAddress.get_path_len() to get the true length of this string.

New in version 2.22.

get_path_len()[source]
Returns:

the length of the path

Return type:

int

Gets the length of self's path.

For details, see Gio.UnixSocketAddress.get_path().

New in version 2.22.

Property Details

Gio.UnixSocketAddress.props.abstract
Name:

abstract

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY

Whether or not this is an abstract address

Deprecated since version ???: Use Gio.UnixSocketAddress :address-type, which distinguishes between zero-padded and non-zero-padded abstract addresses.

Gio.UnixSocketAddress.props.address_type
Name:

address-type

Type:

Gio.UnixSocketAddressType

Default Value:

Gio.UnixSocketAddressType.PATH

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY

The type of UNIX socket address

Gio.UnixSocketAddress.props.path
Name:

path

Type:

str

Default Value:

None

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY

UNIX socket path

Gio.UnixSocketAddress.props.path_as_array
Name:

path-as-array

Type:

GLib.ByteArray

Default Value:

None

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY

UNIX socket path, as byte array