gio.socket_connection
Module for [SocketConnection] class
Types 3
[gio.socket_connection.SocketConnection] is a [gio.iostream.IOStream] for a connected socket. They can be created either by [gio.socket_client.SocketClient] when connecting to a host, or by [gio.socket_listener.SocketListener] when accepting a new client.
The type of the [gio.socket_connection.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 a [gio.tcp_connection.TcpConnection].
Choosing what type of object to construct is done with the socket connection factory, and it is possible for third parties to register custom socket connection types for specific combination of socket family/type/protocol using [gio.socket_connection.SocketConnection.factoryRegisterType].
To close a [gio.socket_connection.SocketConnection], use [gio.iostream.IOStream.close]. Closing both substreams of the [gio.iostream.IOStream] separately will not close the underlying [gio.socket.Socket].
SocketConnection self()Returns `this`, for use in `with` statements.SocketConnectionGidBuilder builder()Get builder for [gio.socket_connection.SocketConnection] Returns: New builder objectgio.socket.Socket socket() @propertyGet `socket` property. Returns: The underlying [gio.socket.Socket].gobject.types.GType factoryLookupType(gio.types.SocketFamily family, gio.types.SocketType type, int protocolId)Looks up the #GType to be used when creating socket connections on sockets with the specified family, type and protocol_id.void factoryRegisterType(gobject.types.GType gType, gio.types.SocketFamily family, gio.types.SocketType type, int protocol)Looks up the #GType to be used when creating socket connections on sockets with the specified family, type and protocol.bool connect(gio.socket_address.SocketAddress address, gio.cancellable.Cancellable cancellable = null)Connect connection to the specified remote address.void connectAsync(gio.socket_address.SocketAddress address, gio.cancellable.Cancellable cancellable = null, gio.types.AsyncReadyCallback callback = null)Asynchronously connect connection to the specified remote address.bool connectFinish(gio.async_result.AsyncResult result)Gets the result of a [gio.socket_connection.SocketConnection.connectAsync] call.gio.socket_address.SocketAddress getLocalAddress()Try to get the local address of a socket connection. Returns: a #GSocketAddress or null on error. Free the returned object with [gobject.object.ObjectWrap.unref]. Throws: [ErrorWrap]gio.socket_address.SocketAddress getRemoteAddress()Try to get the remote address of a socket connection.gio.socket.Socket getSocket()Gets the underlying #GSocket object of the connection. This can be useful if you want to do something unusual on it not supported by the #GSocketConnection APIs. Returns: a #GSocket or null on error.bool isConnected()Checks if connection is connected. This is equivalent to calling [gio.socket.Socket.isConnected] on connection's underlying #GSocket. Returns: whether connection is connectedT socket(gio.socket.Socket propval)Set `socket` property. Params: propval = The underlying [gio.socket.Socket]. Returns: Builder instance for fluent chainingFluent builder for [gio.socket_connection.SocketConnection]