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.IOStream- Abstract: - No - Structure: - Gio.SocketConnectionClass- Gio.SocketConnectionis a- Gio.IOStreamfor a connected socket. They can be created either by- Gio.SocketClientwhen connecting to a host, or by- Gio.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 a- Gio.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, use- Gio.IOStream.close(). Closing both substreams of the- Gio.IOStreamseparately will not close the underlying- Gio.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) – the- Gio.AsyncResult- Raises: - GLib.Error- Returns: - Trueif the connection succeeded,- Falseon error- Return type: - bool- Gets the result of a - Gio.SocketConnection.connect_async() call.- New in version 2.32. 
 - 
get_local_address()[source]¶
- Raises: - GLib.Error- Returns: - a - Gio.SocketAddressor- Noneon error. Free the returned object with- GObject.Object.unref().- Return type: - Gio.SocketAddress- Try to get the local address of a socket connection. - New in version 2.22. 
 - 
get_remote_address()[source]¶
- Raises: - GLib.Error- Returns: - a - Gio.SocketAddressor- Noneon error. Free the returned object with- GObject.Object.unref().- Return type: - Gio.SocketAddress- Try to get the remote address of a socket connection. - Since GLib 2.40, when used with - Gio.SocketClient.connect() or- Gio.SocketClient.connect_async(), during emission of- Gio.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.Socketor- Noneon error.- Return type: - Gio.Socket- Gets the underlying - Gio.Socketobject of the connection. This can be useful if you want to do something unusual on it not supported by the- Gio.SocketConnectionAPIs.- New in version 2.22. 
 - 
is_connected()[source]¶
- Returns: - whether self is connected - Return type: - bool- Checks if self is connected. This is equivalent to calling - Gio.Socket.is_connected() on self’s underlying- Gio.Socket.- New in version 2.32. 
 
- 
classmethod 
Property Details¶
- 
Gio.SocketConnection.props.socket¶
- Name: - socket- Type: - Gio.Socket- Default Value: - None- Flags: - READABLE,- WRITABLE,- CONSTRUCT_ONLY- The underlying - Gio.Socket