Class: Gio::SocketConnection

Inherits:
IOStream show all
Defined in:
(unknown)

Direct Known Subclasses

TcpConnection, UnixConnection

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from IOStream

#clear_pending, #close, #close_async, #close_finish, #closed=, #closed?, #has_pending, #input_stream, #input_stream=, #is_closed, #output_stream, #output_stream=, #set_pending, #splice_async, splice_finish

Class Method Details

.factory_lookup_type(family, type, protocol_id) ⇒ GLib::Type

Looks up the #GType to be used when creating socket connections on sockets with the specified family, type and protocol_id.

If no type is registered, the GSocket::Connection base type is returned.

Parameters:

Returns:

  • (GLib::Type)

    a #GType

.factory_register_type(g_type, family, type, protocol) ⇒ nil

Looks up the #GType to be used when creating socket connections on sockets with the specified family, type and protocol.

If no type is registered, the GSocket::Connection base type is returned.

Parameters:

  • g_type (GLib::Type)

    a #GType, inheriting from %G_TYPE_SOCKET_CONNECTION

  • family (Gio::SocketFamily)

    a GSocket::Family

  • type (Gio::SocketType)

    a GSocket::Type

  • protocol (Integer)

    a protocol id

Returns:

  • (nil)

Instance Method Details

#connect(address, cancellable) ⇒ Boolean

Connect connection to the specified remote address.

Parameters:

Returns:

  • (Boolean)

    true if the connection succeeded, false on error

#connect_async(address, cancellable, callback, user_data) ⇒ nil

Asynchronously connect connection to the specified remote address.

This clears the #GSocket:blocking flag on connection's underlying socket if it is currently set.

If #GSocket:timeout is set, the operation will time out and return %G_IO_ERROR_TIMED_OUT after that period. Otherwise, it will continue indefinitely until operating system timeouts (if any) are hit.

Use g_socket_connection_connect_finish() to retrieve the result.

Parameters:

  • address (Gio::SocketAddress)

    a GSocket::Address specifying the remote address.

  • cancellable (Gio::Cancellable)

    a %GCancellable or nil

  • callback (Gio::AsyncReadyCallback)

    a GAsync::ReadyCallback

  • user_data (GObject)

    user data for the callback

Returns:

  • (nil)

#connect_finish(result) ⇒ Boolean

Gets the result of a g_socket_connection_connect_async() call.

Parameters:

Returns:

  • (Boolean)

    true if the connection succeeded, false on error

#is_connectedBoolean

Checks if connection is connected. This is equivalent to calling g_socket_is_connected() on connection's underlying #GSocket.

Returns:

  • (Boolean)

    whether connection is connected

#local_addressGio::SocketAddress

Try to get the local address of a socket connection.

Returns:

  • (Gio::SocketAddress)

    a GSocket::Address or nil on error. Free the returned object with g_object_unref().

#remote_addressGio::SocketAddress

Try to get the remote address of a socket connection.

Since GLib 2.40, when used with g_socket_client_connect() or g_socket_client_connect_async(), during emission of %G_SOCKET_CLIENT_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)...".

Returns:

  • (Gio::SocketAddress)

    a GSocket::Address or nil on error. Free the returned object with g_object_unref().

#socketGio::Socket

The underlying [classGio.Socket].

Returns:

#socket=(socket) ⇒ Gio::Socket

The underlying [classGio.Socket].

Parameters:

Returns: