pub trait SocketConnectionExt: IsA<SocketConnection> + '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
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.