Class UnixFDMessage
- All Implemented Interfaces:
Proxy
SocketControlMessage
contains a UnixFDList
.
It may be sent using Socket.sendMessage(org.gnome.gio.SocketAddress, org.gnome.gio.OutputVector[], org.gnome.gio.SocketControlMessage[], int, org.gnome.gio.Cancellable)
and received using
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)
over UNIX sockets (ie: sockets in the
G_SOCKET_FAMILY_UNIX
family). The file descriptors are copied
between processes by the kernel.
For an easier way to send and receive file descriptors over
stream-oriented UNIX sockets, see UnixConnection.sendFd(int, org.gnome.gio.Cancellable)
and
UnixConnection.receiveFd(org.gnome.gio.Cancellable)
.
Note that <gio/gunixfdmessage.h>
belongs to the UNIX-specific GIO
interfaces, thus you have to use the gio-unix-2.0.pc
pkg-config
file or the GioUnix-2.0
GIR namespace when using it.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
UnixFDMessage.Builder<B extends UnixFDMessage.Builder<B>>
Inner class implementing a builder pattern to construct a GObject with properties.static class
Nested classes/interfaces inherited from class org.gnome.gio.SocketControlMessage
SocketControlMessage.SocketControlMessageClass, SocketControlMessage.SocketControlMessageImpl
Nested classes/interfaces inherited from class org.gnome.gobject.GObject
GObject.NotifyCallback, GObject.ObjectClass
-
Constructor Summary
ConstructorDescriptionCreates a newGUnixFDMessage
containing an empty file descriptor list.UnixFDMessage
(MemorySegment address) Create a UnixFDMessage proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionboolean
appendFd
(int fd) Adds a file descriptor to this UnixFDMessage.protected UnixFDMessage
asParent()
Returns this instance as if it were its parent type.static UnixFDMessage.Builder
<? extends UnixFDMessage.Builder> builder()
AUnixFDMessage.Builder
object constructs aUnixFDMessage
with the specified properties.Gets theGUnixFDList
contained in this UnixFDMessage.static MemoryLayout
The memory layout of the native struct.static Type
getType()
Get the GType of the UnixFDMessage classint[]
stealFds()
Returns the array of file descriptors that is contained in this object.static UnixFDMessage
withFdList
(UnixFDList fdList) Creates a newGUnixFDMessage
containinglist
.Methods inherited from class org.gnome.gio.SocketControlMessage
deserialize, getLevel, getMsgType, getSize, serialize
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
-
UnixFDMessage
Create a UnixFDMessage proxy instance for the provided memory address.- Parameters:
address
- the memory address of the native object
-
UnixFDMessage
Creates a newGUnixFDMessage
containing an empty file descriptor list.- Throws:
UnsupportedPlatformException
- when run on a platform other than linux or macos
-
-
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.- Overrides:
asParent
in classSocketControlMessage
-
withFdList
Creates a newGUnixFDMessage
containinglist
.- Parameters:
fdList
- aGUnixFDList
- Returns:
- a new
GUnixFDMessage
- Throws:
UnsupportedPlatformException
- when run on a platform other than linux or macos
-
appendFd
Adds a file descriptor to this UnixFDMessage.The file descriptor is duplicated using dup(). You keep your copy of the descriptor and the copy contained in this UnixFDMessage will be closed when this UnixFDMessage is finalized.
A possible cause of failure is exceeding the per-process or system-wide file descriptor limit.
- Parameters:
fd
- a valid open file descriptor- Returns:
true
in case of success, elsefalse
(anderror
is set)- Throws:
GErrorException
- seeGError
-
getFdList
Gets theGUnixFDList
contained in this UnixFDMessage. This function does not return a reference to the caller, but the returned list is valid for the lifetime of this UnixFDMessage.- Returns:
- the
GUnixFDList
from this UnixFDMessage
-
stealFds
public int[] stealFds()Returns the array of file descriptors that is contained in this object.After this call, the descriptors are no longer contained in this UnixFDMessage. Further calls will return an empty list (unless more descriptors have been added).
The return result of this function must be freed with g_free(). The caller is also responsible for closing all of the file descriptors.
If
length
is non-null
then it is set to the number of file descriptors in the returned array. The returned array is also terminated with -1.This function never returns
null
. In case there are no file descriptors contained in this UnixFDMessage, an empty array is returned.- Returns:
- an array of file descriptors
-
builder
AUnixFDMessage.Builder
object constructs aUnixFDMessage
with the specified properties. Use the variousset...()
methods to set properties, and finish construction withUnixFDMessage.Builder.build()
.
-