:right-sidebar: True SocketConnection =================================================================== .. currentmodule:: gi.repository.Gio .. versionadded:: 2.22 .. class:: SocketConnection(**properties: ~typing.Any) :no-contents-entry: Superclasses: :class:`~gi.repository.Gio.IOStream`, :class:`~gi.repository.GObject.Object` Subclasses: :class:`~gi.repository.Gio.TcpConnection`, :class:`~gi.repository.Gio.UnixConnection` :Constructors: :: SocketConnection(**properties) Methods ------- .. rst-class:: interim-class .. class:: SocketConnection :no-index: .. method:: connect(address: ~gi.repository.Gio.SocketAddress, cancellable: ~gi.repository.Gio.Cancellable | None = None) -> bool Connect ``connection`` to the specified remote address. .. versionadded:: 2.32 :param address: a :obj:`~gi.repository.Gio.SocketAddress` specifying the remote address. :param cancellable: a ``%GCancellable`` or :const:`None` .. method:: connect_async(address: ~gi.repository.Gio.SocketAddress, cancellable: ~gi.repository.Gio.Cancellable | None = None, callback: ~typing.Callable[[...], None] | None = None, *user_data: ~typing.Any) -> None Asynchronously connect ``connection`` to the specified remote address. This clears the :obj:`~gi.repository.Gio.Socket`:blocking flag on ``connection``'s underlying socket if it is currently set. If :obj:`~gi.repository.Gio.Socket`:timeout is set, the operation will time out and return :const:`~gi.repository.Gio.IOErrorEnum.TIMED_OUT` after that period. Otherwise, it will continue indefinitely until operating system timeouts (if any) are hit. Use :func:`~gi.repository.Gio.SocketConnection.connect_finish` to retrieve the result. .. versionadded:: 2.32 :param address: a :obj:`~gi.repository.Gio.SocketAddress` specifying the remote address. :param cancellable: a ``%GCancellable`` or :const:`None` :param callback: a :obj:`~gi.repository.Gio.AsyncReadyCallback` :param user_data: user data for the callback .. method:: connect_finish(result: ~gi.repository.Gio.AsyncResult) -> bool Gets the result of a :func:`~gi.repository.Gio.SocketConnection.connect_async` call. .. versionadded:: 2.32 :param result: the :obj:`~gi.repository.Gio.AsyncResult` .. method:: factory_lookup_type(family: ~gi.repository.Gio.SocketFamily, type: ~gi.repository.Gio.SocketType, protocol_id: int) -> type Looks up the :obj:`~gi.repository.GObject.Type` to be used when creating socket connections on sockets with the specified ``family``, ``type`` and ``protocol_id``. If no type is registered, the :obj:`~gi.repository.Gio.SocketConnection` base type is returned. .. versionadded:: 2.22 :param family: a :obj:`~gi.repository.Gio.SocketFamily` :param type: a :obj:`~gi.repository.Gio.SocketType` :param protocol_id: a protocol id .. method:: factory_register_type(g_type: type, family: ~gi.repository.Gio.SocketFamily, type: ~gi.repository.Gio.SocketType, protocol: int) -> None Looks up the :obj:`~gi.repository.GObject.Type` to be used when creating socket connections on sockets with the specified ``family``, ``type`` and ``protocol``. If no type is registered, the :obj:`~gi.repository.Gio.SocketConnection` base type is returned. .. versionadded:: 2.22 :param g_type: a :obj:`~gi.repository.GObject.Type`, inheriting from ``%G_TYPE_SOCKET_CONNECTION`` :param family: a :obj:`~gi.repository.Gio.SocketFamily` :param type: a :obj:`~gi.repository.Gio.SocketType` :param protocol: a protocol id .. method:: get_local_address() -> ~gi.repository.Gio.SocketAddress Try to get the local address of a socket connection. .. versionadded:: 2.22 .. method:: get_remote_address() -> ~gi.repository.Gio.SocketAddress Try to get the remote address of a socket connection. Since GLib 2.40, when used with :func:`~gi.repository.Gio.SocketClient.connect` or :func:`~gi.repository.Gio.SocketClient.connect_async`, during emission of :const:`~gi.repository.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)...". .. versionadded:: 2.22 .. method:: get_socket() -> ~gi.repository.Gio.Socket Gets the underlying :obj:`~gi.repository.Gio.Socket` object of the connection. This can be useful if you want to do something unusual on it not supported by the :obj:`~gi.repository.Gio.SocketConnection` APIs. .. versionadded:: 2.22 .. method:: is_connected() -> bool Checks if ``connection`` is connected. This is equivalent to calling :func:`~gi.repository.Gio.Socket.is_connected` on ``connection``'s underlying :obj:`~gi.repository.Gio.Socket`. .. versionadded:: 2.32 Properties ---------- .. rst-class:: interim-class .. class:: SocketConnection :no-index: .. attribute:: props.socket :type: ~gi.repository.Gio.Socket The underlying :obj:`~gi.repository.Gio.Socket`. .. versionadded:: 2.22 Fields ------ .. rst-class:: interim-class .. class:: SocketConnection :no-index: .. attribute:: parent_instance .. attribute:: priv