Class SocketControlMessage
- All Implemented Interfaces:
Proxy
- Direct Known Subclasses:
SocketControlMessage.SocketControlMessageImpl
,UnixCredentialsMessage
,UnixFDMessage
GSocketControlMessage
is a special-purpose utility message that
can be sent to or received from a 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 Socket.sendMessage(org.gnome.gio.SocketAddress, org.gnome.gio.OutputVector[], org.gnome.gio.SocketControlMessage[], int, org.gnome.gio.Cancellable)
and received
with Socket.receiveMessage(io.github.jwharm.javagi.base.Out<org.gnome.gio.SocketAddress>, org.gnome.gio.InputVector[], io.github.jwharm.javagi.base.Out<org.gnome.gio.SocketControlMessage[]>, io.github.jwharm.javagi.base.Out<java.lang.Integer>, org.gnome.gio.Cancellable)
.
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.Type
type system before calling
Socket.receiveMessage(io.github.jwharm.javagi.base.Out<org.gnome.gio.SocketAddress>, org.gnome.gio.InputVector[], io.github.jwharm.javagi.base.Out<org.gnome.gio.SocketControlMessage[]>, io.github.jwharm.javagi.base.Out<java.lang.Integer>, org.gnome.gio.Cancellable)
to read such a message.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Inner class implementing a builder pattern to construct a GObject with properties.static class
Class structure forGSocketControlMessage
.static class
The SocketControlMessageImpl type represents a native instance of the abstract SocketControlMessage class.Nested classes/interfaces inherited from class org.gnome.gobject.GObject
GObject.NotifyCallback, GObject.ObjectClass
-
Constructor Summary
ConstructorDescriptionSocketControlMessage
(MemorySegment address) Create a SocketControlMessage proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionprotected SocketControlMessage
asParent()
Returns this instance as if it were its parent type.static SocketControlMessage.Builder
<? extends SocketControlMessage.Builder> builder()
ASocketControlMessage.Builder
object constructs aSocketControlMessage
with the specified properties.static SocketControlMessage
deserialize
(int level, int type, byte[] data) Tries to deserialize a socket control message of a givenlevel
andtype
.int
getLevel()
Returns the "level" (i.e.static MemoryLayout
The memory layout of the native struct.int
Returns the protocol specific type of the control message.long
getSize()
Returns the space required for the control message, not including headers or alignment.static Type
getType()
Get the GType of the SocketControlMessage classvoid
serialize
(MemorySegment data) Converts the data in the message to bytes placed in the message.Methods inherited from class org.gnome.gobject.GObject
addToggleRef, addWeakPointer, bindProperty, bindProperty, bindProperty, bindPropertyFull, bindPropertyFull, bindPropertyWithClosures, bindPropertyWithClosures, compatControl, connect, connect, connect, constructed, disconnect, dispatchPropertiesChanged, dispose, dupData, dupQdata, emit, emitNotify, finalize_, forceFloating, freezeNotify, get, getData, getProperty, getProperty, getProperty, getQdata, getv, interfaceFindProperty, interfaceInstallProperty, interfaceListProperties, isFloating, newInstance, newInstance, newInstance, newInstance, newv, notify_, notify_, notifyByPspec, onNotify, ref, refSink, removeToggleRef, removeWeakPointer, replaceData, replaceQdata, runDispose, set, setData, setDataFull, setProperty, setProperty, setProperty, setQdata, setQdataFull, setv, stealData, stealQdata, takeRef, thawNotify, unref, watchClosure, weakRef, weakUnref, withProperties
Methods inherited from class org.gnome.gobject.TypeInstance
callParent, callParent, getPrivate, readGClass, writeGClass
Methods inherited from class io.github.jwharm.javagi.base.ProxyInstance
equals, handle, hashCode
-
Constructor Details
-
SocketControlMessage
Create a SocketControlMessage proxy instance for the provided memory address.- Parameters:
address
- the memory address of the native object
-
-
Method Details
-
getType
-
getMemoryLayout
The memory layout of the native struct.- Returns:
- the memory layout
-
asParent
Returns this instance as if it were its parent type. This is mostly synonymous to the Javasuper
keyword, but will set the native typeclass function pointers to the parent type. When overriding a native virtual method in Java, "chaining up" withsuper.methodName()
doesn't work, because it invokes the overridden function pointer again. To chain up, callasParent().methodName()
. This will call the native function pointer of this virtual method in the typeclass of the parent type. -
deserialize
Tries to deserialize a socket control message of a givenlevel
andtype
. This will ask all known (to GType) subclasses ofGSocketControlMessage
if they can understand this kind of message and if so deserialize it into aGSocketControlMessage
.If there is no implementation for this kind of control message,
null
will be returned.- Parameters:
level
- a socket leveltype
- a socket control message type for the givenlevel
data
- pointer to the message data- Returns:
- the deserialized message or
null
-
getLevel
public int getLevel()Returns the "level" (i.e. the originating protocol) of the control message. This is often SOL_SOCKET.- Returns:
- an integer describing the level
-
getMsgType
public int getMsgType()Returns the protocol specific type of the control message. For instance, for UNIX fd passing this would be SCM_RIGHTS.- Returns:
- an integer describing the type of control message
-
getSize
public long getSize()Returns the space required for the control message, not including headers or alignment.- Returns:
- The number of bytes required.
-
serialize
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.- Parameters:
data
- A buffer to write data to
-
builder
ASocketControlMessage.Builder
object constructs aSocketControlMessage
with the specified properties. Use the variousset...()
methods to set properties, and finish construction withSocketControlMessage.Builder.build()
.
-