Basics

Guides

API Reference

Menu

Basics

Guides

API Reference

class: SocketControlMessage

[24:7] extends: object

A GSocketControlMessage is a special-purpose utility message that can be sent to or received from a [class@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 [method@Gio.Socket.send_message] and received with [method@Gio.Socket.receive_message]. To extend the set of control messages 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 [type@GObject.Type] type system before calling [method@Gio.Socket.receive_message] to read such a message.

Members

  • handleObj
  • lib
  • retainedCallbacks
  • signalHandlerNames
  • signalSetterHandlers

Methods

  • SocketControlMessage (Handle = null)

    Creates a new SocketControlMessage by wrapping a native handle or another wrapper.

    • @p Handle is the native handle or another wrapper whose handle to adopt.
  • toNativeHandle (Source)

    Normalizes a constructor argument into a raw pointer carrier. Accepts a raw NativeHandle, a raw NativeBuffer returned from fn.call(...), another generated wrapper exposing handle(), or null. Returns null when the argument carries no pointer.

    • @p Source is the raw handle, raw buffer, wrapper, or null.
    • @r A raw pointer carrier or null when no pointer is present.
  • getLib ()

    Returns the opened native library for this generated wrapper.

    • @r The opened native library.
  • handle ()

    Returns the wrapped NativeHandle.

    • @r The wrapped NativeHandle.
  • isNull ()

    Returns true when the wrapped handle is null.

    • @r A bool.
  • describe ()

    Returns a small string for debugging generated wrappers.

    • @r A string.
  • asObject ()

    Wraps this handle as Object.

    • @r A Object object.
  • get_level ()

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

  • get_msg_type ()

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

  • get_size ()

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

  • serialize (data)

    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 g_socket_control_message_get_size() on this object.

    • @p data is A buffer to write data to.
    • @r None.