Gio.SocketConnection¶
| Subclasses: | Gio.TcpConnection, Gio.UnixConnection |
|---|
Methods¶
| Inherited: | Gio.IOStream (11), GObject.Object (37) |
|---|---|
| Structs: | GObject.ObjectClass (5) |
| class | factory_lookup_type (family, type, protocol_id) |
| class | factory_register_type (g_type, family, type, protocol) |
connect (address, cancellable) |
|
connect_async (address, cancellable, callback, *user_data) |
|
connect_finish (result) |
|
get_local_address () |
|
get_remote_address () |
|
get_socket () |
|
is_connected () |
Virtual Methods¶
| Inherited: | Gio.IOStream (5), GObject.Object (7) |
|---|
Properties¶
| Inherited: | Gio.IOStream (3) |
|---|
| Name | Type | Flags | Short Description |
|---|---|---|---|
socket |
Gio.Socket |
r/w/co | The underlying Gio.Socket |
Signals¶
| Inherited: | GObject.Object (1) |
|---|
Class Details¶
-
class
Gio.SocketConnection(**kwargs)¶ Bases: Gio.IOStreamAbstract: No Structure: Gio.SocketConnectionClassGio.SocketConnectionis aGio.IOStreamfor a connected socket. They can be created either byGio.SocketClientwhen connecting to a host, or byGio.SocketListenerwhen accepting a new client.The type of the
Gio.SocketConnectionobject returned from these calls depends on the type of the underlying socket that is in use. For instance, for a TCP/IP connection it will be aGio.TcpConnection.Choosing what type of object to construct is done with the socket connection factory, and it is possible for 3rd parties to register custom socket connection types for specific combination of socket family/type/protocol using
Gio.SocketConnection.factory_register_type().To close a
Gio.SocketConnection, useGio.IOStream.close(). Closing both substreams of theGio.IOStreamseparately will not close the underlyingGio.Socket.New in version 2.22.
-
classmethod
factory_lookup_type(family, type, protocol_id)[source]¶ Parameters: - family (
Gio.SocketFamily) – aGio.SocketFamily - type (
Gio.SocketType) – aGio.SocketType - protocol_id (
int) – a protocol id
Returns: Return type: Looks up the
GObject.GTypeto be used when creating socket connections on sockets with the specified family, type and protocol_id.If no type is registered, the
Gio.SocketConnectionbase type is returned.New in version 2.22.
- family (
-
classmethod
factory_register_type(g_type, family, type, protocol)[source]¶ Parameters: - g_type (
GObject.GType) – aGObject.GType, inheriting from %G_TYPE_SOCKET_CONNECTION - family (
Gio.SocketFamily) – aGio.SocketFamily - type (
Gio.SocketType) – aGio.SocketType - protocol (
int) – a protocol id
Looks up the
GObject.GTypeto be used when creating socket connections on sockets with the specified family, type and protocol.If no type is registered, the
Gio.SocketConnectionbase type is returned.New in version 2.22.
- g_type (
-
connect(address, cancellable)[source]¶ Parameters: - address (
Gio.SocketAddress) – aGio.SocketAddressspecifying the remote address. - cancellable (
Gio.CancellableorNone) – aGio.CancellableorNone
Raises: Returns: Return type: Connect self to the specified remote address.
New in version 2.32.
- address (
-
connect_async(address, cancellable, callback, *user_data)[source]¶ Parameters: - address (
Gio.SocketAddress) – aGio.SocketAddressspecifying the remote address. - cancellable (
Gio.CancellableorNone) – aGio.CancellableorNone - callback (
Gio.AsyncReadyCallbackorNone) – aGio.AsyncReadyCallback - user_data (
objectorNone) – user data for the callback
Asynchronously connect self to the specified remote address.
This clears the
Gio.Socket:blockingflag on self’s underlying socket if it is currently set.Use
Gio.SocketConnection.connect_finish() to retrieve the result.New in version 2.32.
- address (
-
connect_finish(result)[source]¶ Parameters: result ( Gio.AsyncResult) – theGio.AsyncResultRaises: GLib.ErrorReturns: Trueif the connection succeeded,Falseon errorReturn type: boolGets the result of a
Gio.SocketConnection.connect_async() call.New in version 2.32.
-
get_local_address()[source]¶ Raises: GLib.ErrorReturns: a Gio.SocketAddressorNoneon error. Free the returned object withGObject.Object.unref().Return type: Gio.SocketAddressTry to get the local address of a socket connection.
New in version 2.22.
-
get_remote_address()[source]¶ Raises: GLib.ErrorReturns: a Gio.SocketAddressorNoneon error. Free the returned object withGObject.Object.unref().Return type: Gio.SocketAddressTry to get the remote address of a socket connection.
Since GLib 2.40, when used with
Gio.SocketClient.connect() orGio.SocketClient.connect_async(), during emission ofGio.SocketClientEvent.CONNECTING, this function will return the remote address that will be used for the connection. This allows applications to print e.g. “Connecting to example.com (10.42.77.3)…”.New in version 2.22.
-
get_socket()[source]¶ Returns: a Gio.SocketorNoneon error.Return type: Gio.SocketGets the underlying
Gio.Socketobject of the connection. This can be useful if you want to do something unusual on it not supported by theGio.SocketConnectionAPIs.New in version 2.22.
-
is_connected()[source]¶ Returns: whether self is connected Return type: boolChecks if self is connected. This is equivalent to calling
Gio.Socket.is_connected() on self’s underlyingGio.Socket.New in version 2.32.
-
classmethod
Property Details¶
-
Gio.SocketConnection.props.socket¶ Name: socketType: Gio.SocketDefault Value: NoneFlags: READABLE,WRITABLE,CONSTRUCT_ONLYThe underlying
Gio.Socket