Gio.UnixSocketAddress.new_with_type
function new_with_type(path: Array(Number(gchar)), type: Gio.UnixSocketAddressType): Gio.SocketAddress { // Gjs wrapper for g_unix_socket_address_new_with_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 @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.prototype.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.prototype.get_native_size will always return the full size of a `struct sockaddr_un`, although Gio.UnixSocketAddress.prototype.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.
Since 2.26
- path
the name
- type
- Returns
a new Gio.UnixSocketAddress