Gio.UnixSocketAddress - Classes - Gio 2.0 (original) (raw)
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:
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:
Name | Type | Flags | Short Description |
---|---|---|---|
abstract | bool | r/w/co | deprecated |
address-type | Gio.UnixSocketAddressType | r/w/co | |
path | str | r/w/co | |
path-as-array | GLib.ByteArray | r/w/co |
Signals¶
Inherited:
Fields¶
Inherited:
Name | Type | Access | Description |
---|---|---|---|
parent_instance | Gio.SocketAddress | r |
Class Details¶
class Gio.UnixSocketAddress(**kwargs)¶
Bases:
Abstract:
No
Structure:
Support for UNIX-domain (also known as local) sockets, corresponding tostruct 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 G_IO_ERROR_NOT_SUPPORTED
errors. You can use [func`Gio`.UnixSocketAddress.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.
classmethod abstract_names_supported()[source]¶
Returns:
True if supported, False otherwise
Return type:
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:
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:
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:
- path ([int]) – the name
- type (Gio.UnixSocketAddressType) – a Gio.UnixSocketAddressType
Returns:
a new Gio.UnixSocketAddress
Return type:
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_lenbytes 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 pathwas “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, thenpath_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, ifpath_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
, althoughGio.UnixSocketAddress.get_path_len() will still return just the length of path.
Gio.UnixSocketAddressType.ABSTRACT is preferred overGio.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.
Returns:
Return type:
Gets self's type.
New in version 2.26.
Returns:
True if the address is abstract, False otherwise
Return type:
Tests if self is abstract.
New in version 2.22.
Deprecated since version ???: Use Gio.UnixSocketAddress.get_address_type()
Returns:
the path for self
Return type:
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 useGio.UnixSocketAddress.get_path_len() to get the true length of this string.
New in version 2.22.
Returns:
the length of the path
Return type:
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:
Default Value:
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:
Default Value:
Gio.UnixSocketAddressType.PATH
Flags:
READABLE, WRITABLE, CONSTRUCT_ONLY
The type of Unix socket address.
New in version 2.22.
Gio.UnixSocketAddress.props.path¶
Name:
path
Type:
Default Value:
Flags:
READABLE, WRITABLE, CONSTRUCT_ONLY
Unix socket path.
New in version 2.22.
Gio.UnixSocketAddress.props.path_as_array¶
Name:
path-as-array
Type:
Default Value:
Flags:
READABLE, WRITABLE, CONSTRUCT_ONLY
Unix socket path, as a byte array.
New in version 2.22.