[][src]Trait gio::SocketConnectionExt

pub trait SocketConnectionExt: 'static {
    fn connect<P: IsA<SocketAddress>, Q: IsA<Cancellable>>(
        &self,
        address: &P,
        cancellable: Option<&Q>
    ) -> Result<(), Error>;
fn connect_async<P: IsA<SocketAddress>, Q: IsA<Cancellable>, R: FnOnce(Result<(), Error>) + Send + 'static>(
        &self,
        address: &P,
        cancellable: Option<&Q>,
        callback: R
    );
fn connect_async_future<P: IsA<SocketAddress> + Clone + 'static>(
        &self,
        address: &P
    ) -> Pin<Box_<dyn Future<Output = Result<(), Error>> + 'static>>;
fn get_local_address(&self) -> Result<SocketAddress, Error>;
fn get_remote_address(&self) -> Result<SocketAddress, Error>;
fn get_socket(&self) -> Option<Socket>;
fn is_connected(&self) -> bool; }

Trait containing all SocketConnection methods.

Implementors

SocketConnection, TcpConnection

Required methods

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

Connect self to the specified remote address.

address

a SocketAddress specifying the remote address.

cancellable

a Cancellable or None

Returns

true if the connection succeeded, false on error

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

Asynchronously connect self to the specified remote address.

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

Use SocketConnectionExt::connect_finish to retrieve the result.

address

a SocketAddress specifying the remote address.

cancellable

a Cancellable or None

callback

a GAsyncReadyCallback

user_data

user data for the callback

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

fn get_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 gobject::ObjectExt::unref.

fn get_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 gobject::ObjectExt::unref.

fn get_socket(&self) -> Option<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.

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

Loading content...

Implementors

impl<O: IsA<SocketConnection>> SocketConnectionExt for O[src]

Loading content...