Gio.SocketConnection¶
- Subclasses:
Methods¶
- Inherited:
- Structs:
class |
|
class |
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
- Inherited:
Properties¶
- Inherited:
Name |
Type |
Flags |
Short Description |
---|---|---|---|
r/w/co |
The underlying |
Signals¶
- Inherited:
Fields¶
- Inherited:
Name |
Type |
Access |
Description |
---|---|---|---|
parent_instance |
r |
Class Details¶
- class Gio.SocketConnection(**kwargs)¶
- Bases:
- Abstract:
No
- Structure:
Gio.SocketConnection
is aGio.IOStream
for a connected socket. They can be created either byGio.SocketClient
when connecting to a host, or byGio.SocketListener
when accepting a new client.The type of the
Gio.SocketConnection
object 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.IOStream
separately 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.GType
to be used when creating socket connections on sockets with the specified family, type and protocol_id.If no type is registered, the
Gio.SocketConnection
base type is returned.New in version 2.22.
- classmethod factory_register_type(g_type, family, type, protocol)[source]¶
- Parameters:
g_type (
GObject.GType
) – aGObject.GType
, inheriting from %G_TYPE_SOCKET_CONNECTIONfamily (
Gio.SocketFamily
) – aGio.SocketFamily
type (
Gio.SocketType
) – aGio.SocketType
protocol (
int
) – a protocol id
Looks up the
GObject.GType
to be used when creating socket connections on sockets with the specified family, type and protocol.If no type is registered, the
Gio.SocketConnection
base type is returned.New in version 2.22.
- connect(address, cancellable)[source]¶
- Parameters:
address (
Gio.SocketAddress
) – aGio.SocketAddress
specifying the remote address.cancellable (
Gio.Cancellable
orNone
) – aGio.Cancellable
orNone
- Raises:
- Returns:
- Return type:
Connect self to the specified remote address.
New in version 2.32.
- connect_async(address, cancellable, callback, *user_data)[source]¶
- Parameters:
address (
Gio.SocketAddress
) – aGio.SocketAddress
specifying the remote address.cancellable (
Gio.Cancellable
orNone
) – aGio.Cancellable
orNone
callback (
Gio.AsyncReadyCallback
orNone
) – aGio.AsyncReadyCallback
Asynchronously connect self to the specified remote address.
This clears the
Gio.Socket
:blocking
flag on self's underlying socket if it is currently set.Use
Gio.SocketConnection.connect_finish
() to retrieve the result.New in version 2.32.
- connect_finish(result)[source]¶
- Parameters:
result (
Gio.AsyncResult
) – theGio.AsyncResult
- Raises:
- Returns:
- Return type:
Gets the result of a
Gio.SocketConnection.connect_async
() call.New in version 2.32.
- get_local_address()[source]¶
- Raises:
- Returns:
a
Gio.SocketAddress
orNone
on error. Free the returned object withGObject.Object.unref
().- Return type:
Try to get the local address of a socket connection.
New in version 2.22.
- get_remote_address()[source]¶
- Raises:
- Returns:
a
Gio.SocketAddress
orNone
on error. Free the returned object withGObject.Object.unref
().- Return type:
Try 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.Socket
orNone
on error.- Return type:
Gets the underlying
Gio.Socket
object of the connection. This can be useful if you want to do something unusual on it not supported by theGio.SocketConnection
APIs.New in version 2.22.
- is_connected()[source]¶
- Returns:
whether self is connected
- Return type:
Checks if self is connected. This is equivalent to calling
Gio.Socket.is_connected
() on self's underlyingGio.Socket
.New in version 2.32.
Property Details¶
- Gio.SocketConnection.props.socket¶
- Name:
socket
- Type:
- Default Value:
- Flags:
The underlying
Gio.Socket