pub trait SocketConnectionExt: 'static {
    // Required methods
    fn connect(
        &self,
        address: &impl IsA<SocketAddress>,
        cancellable: Option<&impl IsA<Cancellable>>
    ) -> Result<(), Error>;
    fn connect_async<P: FnOnce(Result<(), Error>) + 'static>(
        &self,
        address: &impl IsA<SocketAddress>,
        cancellable: Option<&impl IsA<Cancellable>>,
        callback: P
    );
    fn connect_future(
        &self,
        address: &impl IsA<SocketAddress> + Clone + 'static
    ) -> Pin<Box_<dyn Future<Output = Result<(), Error>> + 'static>>;
    fn local_address(&self) -> Result<SocketAddress, Error>;
    fn remote_address(&self) -> Result<SocketAddress, Error>;
    fn socket(&self) -> Socket;
    fn is_connected(&self) -> bool;
}
Expand description

Required Methods§

source

fn connect( &self, address: &impl IsA<SocketAddress>, cancellable: Option<&impl IsA<Cancellable>> ) -> Result<(), Error>

Connect self to the specified remote address.

address

a SocketAddress specifying the remote address.

cancellable

a GCancellable or None

Returns

true if the connection succeeded, false on error

source

fn connect_async<P: FnOnce(Result<(), Error>) + 'static>( &self, address: &impl IsA<SocketAddress>, cancellable: Option<&impl IsA<Cancellable>>, callback: P )

Asynchronously connect self to the specified remote address.

This clears the blocking flag on self’s underlying socket if it is currently set.

Use g_socket_connection_connect_finish() to retrieve the result.

address

a SocketAddress specifying the remote address.

cancellable

a GCancellable or None

callback

a GAsyncReadyCallback

source

fn connect_future( &self, address: &impl IsA<SocketAddress> + Clone + 'static ) -> Pin<Box_<dyn Future<Output = Result<(), Error>> + 'static>>

source

fn local_address(&self) -> Result<SocketAddress, Error>

Try to get the local address of a socket connection.

Returns

a SocketAddress or None on error. Free the returned object with g_object_unref().

source

fn remote_address(&self) -> Result<SocketAddress, Error>

Try to get the remote address of a socket connection.

Since GLib 2.40, when used with SocketClientExt::connect() or SocketClientExt::connect_async(), during emission of 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)…”.

Returns

a SocketAddress or None on error. Free the returned object with g_object_unref().

source

fn socket(&self) -> Socket

Gets the underlying Socket object of the connection. This can be useful if you want to do something unusual on it not supported by the SocketConnection APIs.

Returns

a Socket or None on error.

source

fn is_connected(&self) -> bool

Checks if self is connected. This is equivalent to calling SocketExt::is_connected() on self’s underlying Socket.

Returns

whether self is connected

Implementors§