1.99 <GUnixConnection>

Class: <GUnixConnection>

It derives from <GSocketConnection>.

This is the subclass of <GSocketConnection> that is created for UNIX domain sockets.

It contains functions to do some of the UNIX socket specific functionality like passing file descriptors.

Since GLib 2.72, <GUnixConnection> 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/gunixconnection.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
priv

Procedures

Method: unix-connection:receive-credentials self [cancellable] ⇒ %return
Method: receive-credentials self [cancellable] ⇒ %return

Receives credentials from the sending end of the connection. The sending end has to call unix-connection:send-credentials? (or similar) for this to work.

As well as reading the credentials this also reads (and discards) a single byte from the stream, as this is required for credentials passing to work on some implementations.

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

  • Linux since GLib 2.26
  • FreeBSD since GLib 2.26
  • GNU/kFreeBSD since GLib 2.36
  • Solaris, Illumos and OpenSolaris since GLib 2.40
  • GNU/Hurd since GLib 2.40

Other ways to exchange credentials with a foreign peer includes the <GUnixCredentialsMessage> type and socket:get-credentials function.

self

Passed: a <GUnixConnection>.

A <GUnixConnection>.

cancellable

Passed, or left out: a <GCancellable>, or #f.

A <GCancellable> or #f.

%return

Returned: a <GCredentials>.

Received credentials on success (free with object:unref), #f if error is set.

Method: unix-connection:receive-credentials-async self [cancellable] [callback]
Method: receive-credentials-async self [cancellable] [callback]

Asynchronously receive credentials.

For more details, see unix-connection:receive-credentials which is the synchronous version of this call.

When the operation is finished, callback will be called. You can then call unix-connection:receive-credentials-finish to get the result of the operation.

self

Passed: a <GUnixConnection>.

A <GUnixConnection>.

cancellable

Passed, or left out: a <GCancellable>, or #f.

optional <GCancellable> object, #f to ignore.

callback

Passed, or left out: a procedure, or #f.

a GAsyncReadyCallback to call when the request is satisfied

See GAsyncReadyCallback for how it is called.

user-data

Not passed: guile-gi supplies it.

the data to pass to callback function

Method: unix-connection:receive-credentials-finish self result ⇒ %return
Method: receive-credentials-finish self result ⇒ %return

Finishes an asynchronous receive credentials operation started with unix-connection:receive-credentials-async.

self

Passed: a <GUnixConnection>.

A <GUnixConnection>.

result

Passed: a <GAsyncResult>.

a <GAsyncResult>.

%return

Returned: a <GCredentials>.

a <GCredentials>, or #f on error. Free the returned object with object:unref.

Method: unix-connection:receive-fd self [cancellable] ⇒ %return
Method: receive-fd self [cancellable] ⇒ %return

Receives a file descriptor from the sending end of the connection. The sending end has to call unix-connection:send-fd? for this to work.

As well as reading the fd this also reads a single byte from the stream, as this is required for fd passing to work on some implementations.

self

Passed: a <GUnixConnection>.

a <GUnixConnection>

cancellable

Passed, or left out: a <GCancellable>, or #f.

optional <GCancellable> object, #f to ignore

%return

Returned: a 32-bit integer.

a file descriptor on success, -1 on error.

Method: unix-connection:send-credentials-async self [cancellable] [callback]
Method: send-credentials-async self [cancellable] [callback]

Asynchronously send credentials.

For more details, see unix-connection:send-credentials? which is the synchronous version of this call.

When the operation is finished, callback will be called. You can then call unix-connection:send-credentials-finish? to get the result of the operation.

self

Passed: a <GUnixConnection>.

A <GUnixConnection>.

cancellable

Passed, or left out: a <GCancellable>, or #f.

optional <GCancellable> object, #f to ignore.

callback

Passed, or left out: a procedure, or #f.

a GAsyncReadyCallback to call when the request is satisfied

See GAsyncReadyCallback for how it is called.

user-data

Not passed: guile-gi supplies it.

the data to pass to callback function

Method: unix-connection:send-credentials-finish? self result ⇒ %return
Method: send-credentials-finish? self result ⇒ %return

Finishes an asynchronous send credentials operation started with unix-connection:send-credentials-async.

self

Passed: a <GUnixConnection>.

A <GUnixConnection>.

result

Passed: a <GAsyncResult>.

a <GAsyncResult>.

%return

Returned: a boolean.

#t if the operation was successful, otherwise #f.

Method: unix-connection:send-credentials? self [cancellable] ⇒ %return
Method: send-credentials? self [cancellable] ⇒ %return

Passes the credentials of the current user the receiving side of the connection. The receiving end has to call unix-connection:receive-credentials (or similar) to accept the credentials.

As well as sending the credentials this also writes a single NUL byte to the stream, as this is required for credentials passing to work on some implementations.

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

  • Linux since GLib 2.26
  • FreeBSD since GLib 2.26
  • GNU/kFreeBSD since GLib 2.36
  • Solaris, Illumos and OpenSolaris since GLib 2.40
  • GNU/Hurd since GLib 2.40

Other ways to exchange credentials with a foreign peer includes the <GUnixCredentialsMessage> type and socket:get-credentials function.

self

Passed: a <GUnixConnection>.

A <GUnixConnection>.

cancellable

Passed, or left out: a <GCancellable>, or #f.

A <GCancellable> or #f.

%return

Returned: a boolean.

#t on success, #f if error is set.

Method: unix-connection:send-fd? self fd [cancellable] ⇒ %return
Method: send-fd? self fd [cancellable] ⇒ %return

Passes a file descriptor to the receiving side of the connection. The receiving end has to call unix-connection:receive-fd to accept the file descriptor.

As well as sending the fd this also writes a single byte to the stream, as this is required for fd passing to work on some implementations.

self

Passed: a <GUnixConnection>.

a <GUnixConnection>

fd

Passed: a 32-bit integer.

a file descriptor

cancellable

Passed, or left out: a <GCancellable>, or #f.

optional <GCancellable> object, #f to ignore.

%return

Returned: a boolean.

a #t on success, #f on error.