Gio.SocketControlMessage

g GObject.Object GObject.Object Gio.SocketControlMessage Gio.SocketControlMessage GObject.Object->Gio.SocketControlMessage

Subclasses:

Gio.UnixCredentialsMessage, Gio.UnixFDMessage

Methods

Inherited:

GObject.Object (37)

Structs:

GObject.ObjectClass (5)

class

deserialize (level, type, data)

get_level ()

get_msg_type ()

get_size ()

serialize (data)

Virtual Methods

Inherited:

GObject.Object (7)

do_get_level ()

do_get_size ()

do_get_type ()

do_serialize (data)

Properties

None

Signals

Inherited:

GObject.Object (1)

Fields

Inherited:

GObject.Object (1)

Name

Type

Access

Description

parent_instance

GObject.Object

r

Class Details

class Gio.SocketControlMessage(**kwargs)
Bases:

GObject.Object

Abstract:

Yes

Structure:

Gio.SocketControlMessageClass

A Gio.SocketControlMessage is a special-purpose utility message that can be sent to or received from a Gio.Socket. These types of messages are often called “ancillary data”.

The message can represent some sort of special instruction to or information from the socket or can represent a special kind of transfer to the peer (for example, sending a file descriptor over a UNIX socket).

These messages are sent with Gio.Socket.send_message() and received with Gio.Socket.receive_message().

To extend the set of control message that can be sent, subclass this class and override the get_size, get_level, get_type and serialize methods.

To extend the set of control messages that can be received, subclass this class and implement the deserialize method. Also, make sure your class is registered with the GObject.GType typesystem before calling Gio.Socket.receive_message() to read such a message.

New in version 2.22.

classmethod deserialize(level, type, data)[source]
Parameters:
  • level (int) – a socket level

  • type (int) – a socket control message type for the given level

  • data (bytes) – pointer to the message data

Returns:

the deserialized message or None

Return type:

Gio.SocketControlMessage or None

Tries to deserialize a socket control message of a given level and type. This will ask all known (to GObject.GType) subclasses of Gio.SocketControlMessage if they can understand this kind of message and if so deserialize it into a Gio.SocketControlMessage.

If there is no implementation for this kind of control message, None will be returned.

New in version 2.22.

get_level()[source]
Returns:

an integer describing the level

Return type:

int

Returns the “level” (i.e. the originating protocol) of the control message. This is often SOL_SOCKET.

New in version 2.22.

get_msg_type()[source]
Returns:

an integer describing the type of control message

Return type:

int

Returns the protocol specific type of the control message. For instance, for UNIX fd passing this would be SCM_RIGHTS.

New in version 2.22.

get_size()[source]
Returns:

The number of bytes required.

Return type:

int

Returns the space required for the control message, not including headers or alignment.

New in version 2.22.

serialize(data)[source]
Parameters:

data (object) – A buffer to write data to

Converts the data in the message to bytes placed in the message.

data is guaranteed to have enough space to fit the size returned by Gio.SocketControlMessage.get_size() on this object.

New in version 2.22.

do_get_level() virtual
Returns:

an integer describing the level

Return type:

int

Returns the “level” (i.e. the originating protocol) of the control message. This is often SOL_SOCKET.

New in version 2.22.

do_get_size() virtual
Returns:

The number of bytes required.

Return type:

int

Returns the space required for the control message, not including headers or alignment.

New in version 2.22.

do_get_type() virtual
Return type:

int

do_serialize(data) virtual
Parameters:

data (object) – A buffer to write data to

Converts the data in the message to bytes placed in the message.

data is guaranteed to have enough space to fit the size returned by Gio.SocketControlMessage.get_size() on this object.

New in version 2.22.