Package ch.bailu.gtk.gio
Klasse SocketListener
java.lang.Object
ch.bailu.gtk.type.Type
ch.bailu.gtk.type.Pointer
ch.bailu.gtk.gobject.Object
ch.bailu.gtk.type.PropertyHolder
ch.bailu.gtk.gio.SocketListener
- Alle implementierten Schnittstellen:
PointerInterface
- Bekannte direkte Unterklassen:
SocketService
A `GSocketListener` is an object that keeps track of a set
of server sockets and helps you accept sockets from any of the
socket, either sync or async.
Add addresses and ports to listen on using
[method@Gio.SocketListener.add_address] and
[method@Gio.SocketListener.add_inet_port]. These will be listened on until
[method@Gio.SocketListener.close] is called. Dropping your final reference to
the `GSocketListener` will not cause [method@Gio.SocketListener.close] to be
called implicitly, as some references to the `GSocketListener` may be held
internally.
If you want to implement a network server, also look at
[class@Gio.SocketService] and [class@Gio.ThreadedSocketService] which are
subclasses of `GSocketListener` that make this even easier.
of server sockets and helps you accept sockets from any of the
socket, either sync or async.
Add addresses and ports to listen on using
[method@Gio.SocketListener.add_address] and
[method@Gio.SocketListener.add_inet_port]. These will be listened on until
[method@Gio.SocketListener.close] is called. Dropping your final reference to
the `GSocketListener` will not cause [method@Gio.SocketListener.close] to be
called implicitly, as some references to the `GSocketListener` may be held
internally.
If you want to implement a network server, also look at
[class@Gio.SocketService] and [class@Gio.ThreadedSocketService] which are
subclasses of `GSocketListener` that make this even easier.
-
Verschachtelte Klassen - Übersicht
Verschachtelte KlassenModifizierer und TypKlasseBeschreibungstatic interface
static interface
Von Klasse geerbte verschachtelte Klassen/Schnittstellen ch.bailu.gtk.gobject.Object
Object.OnBindingTransformFunc, Object.OnDestroyNotify, Object.OnDuplicateFunc, Object.OnNotify, Object.OnToggleNotify, Object.OnWeakNotify
-
Feldübersicht
FelderVon Klasse geerbte Felder ch.bailu.gtk.gobject.Object
SIGNAL_ON_NOTIFY
-
Konstruktorübersicht
KonstruktorenKonstruktorBeschreibungCreates a new #GSocketListener with no sockets to listen for.SocketListener
(PointerContainer pointer) -
Methodenübersicht
Modifizierer und TypMethodeBeschreibungvoid
acceptAsync
(Cancellable cancellable, SocketListener.OnAsyncReadyCallback callback, Pointer user_data) This is the asynchronous version of g_socket_listener_accept().void
acceptSocketAsync
(Cancellable cancellable, SocketListener.OnAsyncReadyCallback callback, Pointer user_data) This is the asynchronous version of g_socket_listener_accept_socket().int
addAnyInetPort
(Object source_object) Listens for TCP connections on any available port number for both
IPv6 and IPv4 (if each is available).boolean
addInetPort
(int port, Object source_object) Helper function for g_socket_listener_add_address() that
creates a TCP/IP socket listening on IPv4 and IPv6 (if
supported) on the specified port on all interfaces.boolean
Adds @socket to the set of sockets that we try to accept
new clients from.void
close()
Closes all the sockets in the listener.static ClassHandler
static int
static long
static TypeSystem.TypeSize
static long
static TypeSystem.TypeSize
onEvent
(SocketListener.OnEvent signal) Connect to signal "event".void
setBacklog
(int listen_backlog) Sets the listen backlog on the sockets in the listener.Von Klasse geerbte Methoden ch.bailu.gtk.type.PropertyHolder
getBooleanProperty, getIntProperty, getObjectProperty, getStringProperty, getStrProperty, setBooleanProperty, setIntProperty, setObjectProperty, setStringProperty, setStrProperty
Von Klasse geerbte Methoden ch.bailu.gtk.gobject.Object
addToggleRef, bindProperty, bindProperty, bindPropertyFull, bindPropertyFull, bindPropertyWithClosures, bindPropertyWithClosures, compatControl, connect, connect, disconnect, disconnect, dupData, dupData, dupQdata, forceFloating, freezeNotify, get, get, getData, getData, getProperty, getProperty, getQdata, interfaceFindProperty, interfaceInstallProperty, isFloating, notify, notify, notifyByPspec, onNotify, ref, refSink, removeToggleRef, replaceData, replaceData, replaceQdata, runDispose, set, set, setData, setData, setDataFull, setDataFull, setProperty, setProperty, setQdata, setQdataFull, stealData, stealData, stealQdata, takeRef, thawNotify, unref, watchClosure, weakRef, weakUnref
Von Klasse geerbte Methoden ch.bailu.gtk.type.Pointer
asCPointer, cast, connectSignal, disconnectSignals, disconnectSignals, equals, hashCode, throwIfNull, throwNullPointerException, toString, unregisterCallbacks, unregisterCallbacks
Von Klasse geerbte Methoden ch.bailu.gtk.type.Type
asCPointer, asCPointer, asCPointerNotNull, asJnaPointer, asJnaPointer, asPointer, asPointer, cast, cast, throwIfNull
Von Klasse geerbte Methoden java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Von Schnittstelle geerbte Methoden ch.bailu.gtk.type.PointerInterface
asCPointerNotNull, asJnaPointer, asPointer, isNotNull, isNull
-
Felddetails
-
SIGNAL_ON_EVENT
- Siehe auch:
-
-
Konstruktordetails
-
SocketListener
-
SocketListener
public SocketListener()Creates a new #GSocketListener with no sockets to listen for.
New listeners can be added with e.g. g_socket_listener_add_address()
or g_socket_listener_add_inet_port().
-
-
Methodendetails
-
getClassHandler
-
acceptAsync
public void acceptAsync(@Nullable Cancellable cancellable, SocketListener.OnAsyncReadyCallback callback, @Nullable Pointer user_data) This is the asynchronous version of g_socket_listener_accept().
When the operation is finished @callback will be
called. You can then call g_socket_listener_accept_finish()
to get the result of the operation.- Parameter:
cancellable
- a #GCancellable, or %NULLcallback
- a #GAsyncReadyCallbackuser_data
- user data for the callback
-
acceptSocketAsync
public void acceptSocketAsync(@Nullable Cancellable cancellable, SocketListener.OnAsyncReadyCallback callback, @Nullable Pointer user_data) This is the asynchronous version of g_socket_listener_accept_socket().
When the operation is finished @callback will be
called. You can then call g_socket_listener_accept_socket_finish()
to get the result of the operation.- Parameter:
cancellable
- a #GCancellable, or %NULLcallback
- a #GAsyncReadyCallbackuser_data
- user data for the callback
-
addAnyInetPort
Listens for TCP connections on any available port number for both
IPv6 and IPv4 (if each is available).
This is useful if you need to have a socket for incoming connections
but don't care about the specific port number.
@source_object will be passed out in the various calls
to accept to identify this particular source, which is
useful if you're listening on multiple addresses and do
different things depending on what address is connected to.- Parameter:
source_object
- Optional #GObject identifying this source- Gibt zurück:
- the port number, or 0 in case of failure.
- Löst aus:
AllocationError
-
addInetPort
Helper function for g_socket_listener_add_address() that
creates a TCP/IP socket listening on IPv4 and IPv6 (if
supported) on the specified port on all interfaces.
@source_object will be passed out in the various calls
to accept to identify this particular source, which is
useful if you're listening on multiple addresses and do
different things depending on what address is connected to.
Call g_socket_listener_close() to stop listening on @port; this will not
be done automatically when you drop your final reference to @listener, as
references may be held internally.- Parameter:
port
- an IP port number (non-zero)source_object
- Optional #GObject identifying this source- Gibt zurück:
- %TRUE on success, %FALSE on error.
- Löst aus:
AllocationError
-
addSocket
public boolean addSocket(@Nonnull Socket socket, @Nullable Object source_object) throws AllocationError Adds @socket to the set of sockets that we try to accept
new clients from. The socket must be bound to a local
address and listened to.
@source_object will be passed out in the various calls
to accept to identify this particular source, which is
useful if you're listening on multiple addresses and do
different things depending on what address is connected to.
The @socket will not be automatically closed when the @listener is finalized
unless the listener held the final reference to the socket. Before GLib 2.42,
the @socket was automatically closed on finalization of the @listener, even
if references to it were held elsewhere.- Parameter:
socket
- a listening #GSocketsource_object
- Optional #GObject identifying this source- Gibt zurück:
- %TRUE on success, %FALSE on error.
- Löst aus:
AllocationError
-
close
public void close()Closes all the sockets in the listener. -
setBacklog
public void setBacklog(int listen_backlog) Sets the listen backlog on the sockets in the listener. This must be called
before adding any sockets, addresses or ports to the #GSocketListener (for
example, by calling g_socket_listener_add_inet_port()) to be effective.
See g_socket_set_listen_backlog() for details- Parameter:
listen_backlog
- an integer
-
onEvent
Connect to signal "event".
SeeSocketListener.OnEvent.onEvent(int, ch.bailu.gtk.gio.Socket)
for signal description.
FieldSIGNAL_ON_EVENT
contains original signal name and can be used as resource reference.- Parameter:
signal
- callback function (lambda).- Gibt zurück:
SignalHandler
. Can be used to disconnect signal and to release callback function.
-
getTypeID
public static long getTypeID() -
getParentTypeID
public static long getParentTypeID() -
getTypeSize
-
getParentTypeSize
-
getInstanceSize
public static int getInstanceSize()
-