Trait gio::prelude::SocketConnectionExt
source · pub trait SocketConnectionExt: IsA<SocketConnection> + Sealed + 'static {
// Provided 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
Provided Methods§
sourcefn connect(
&self,
address: &impl IsA<SocketAddress>,
cancellable: Option<&impl IsA<Cancellable>>,
) -> Result<(), Error>
fn connect( &self, address: &impl IsA<SocketAddress>, cancellable: Option<&impl IsA<Cancellable>>, ) -> Result<(), Error>
sourcefn connect_async<P: FnOnce(Result<(), Error>) + 'static>(
&self,
address: &impl IsA<SocketAddress>,
cancellable: Option<&impl IsA<Cancellable>>,
callback: P,
)
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 #GSocket:blocking flag on @self’s underlying socket if it is currently set.
If #GSocket:timeout is set, the operation will time out and return
IOErrorEnum::TimedOut
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.
§address
a #GSocketAddress specifying the remote address.
§cancellable
a GCancellable
or None
§callback
a #GAsyncReadyCallback
fn connect_future( &self, address: &(impl IsA<SocketAddress> + Clone + 'static), ) -> Pin<Box_<dyn Future<Output = Result<(), Error>> + 'static>>
sourcefn local_address(&self) -> Result<SocketAddress, Error>
fn local_address(&self) -> Result<SocketAddress, Error>
sourcefn remote_address(&self) -> Result<SocketAddress, Error>
fn remote_address(&self) -> Result<SocketAddress, Error>
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
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 #GSocketAddress or None
on error.
Free the returned object with g_object_unref().
sourcefn is_connected(&self) -> bool
fn is_connected(&self) -> bool
Checks if @self is connected. This is equivalent to calling g_socket_is_connected() on @self’s underlying #GSocket.
§Returns
whether @self is connected