Socket.getCredentials

Returns the credentials of the foreign process connected to this socket, if any (e.g. it is only supported for G_SOCKET_FAMILY_UNIX sockets).

If this operation isn't supported on the OS, the method fails with the G_IO_ERROR_NOT_SUPPORTED error. On Linux this is implemented by reading the SO_PEERCRED option on the underlying socket.

This method can be expected to be available on the following platforms:

- Linux since GLib 2.26 - OpenBSD since GLib 2.30 - Solaris, Illumos and OpenSolaris since GLib 2.40 - NetBSD since GLib 2.42

Other ways to obtain credentials from a foreign peer includes the gio.UnixCredentialsMessage type and UnixConnection.sendCredentials / UnixConnection.receiveCredentials functions.

class Socket
getCredentials
()

Return Value

NULL if error is set, otherwise a gio.Credentials object that must be freed with g_object_unref().

Throws

GException on failure.

Meta

Since

2.26