pub struct SplitSocketHandle { /* private fields */ }Expand description
A handle to a split socket.
Created by calling Socket::split. This allows a socket to be split into
two handles that can be used independently in different async tasks (e.g., one
for reading and one for writing).
Each handle maintains its own LTE link and can be deactivated independently, though the underlying socket is only closed when the last handle is dropped.
Implementations§
Source§impl SplitSocketHandle
impl SplitSocketHandle
Sourcepub async fn deactivate(self) -> Result<(), Error>
pub async fn deactivate(self) -> Result<(), Error>
Deactivates this socket handle and its LTE link.
This will deactivate the LTE link associated with this handle. If this is the last remaining handle to the split socket, the underlying socket will also be closed.
A normal drop will do the same thing, but blocking.
Methods from Deref<Target = Socket>§
Sourcepub fn as_raw_fd(&self) -> i32
pub fn as_raw_fd(&self) -> i32
Get the nrf-modem file descriptor so the user can opt out of using this high level wrapper for things
Sourcepub async fn connect(&self, address: SocketAddr) -> Result<(), Error>
pub async fn connect(&self, address: SocketAddr) -> Result<(), Error>
Connect to the given socket address.
This calls the nrfxlib_sys::nrf_connect function and can be used for tcp streams, udp connections and dtls connections.
Sourcepub async unsafe fn connect_with_cancellation(
&self,
address: SocketAddr,
token: &CancellationToken,
) -> Result<(), Error>
pub async unsafe fn connect_with_cancellation( &self, address: SocketAddr, token: &CancellationToken, ) -> Result<(), Error>
Connect to the given socket address.
This calls the nrfxlib_sys::nrf_connect function and can be used for tcp streams, udp connections and dtls connections.
§Safety
If the connect is cancelled, the socket may be in a weird state and should be dropped.
Sourcepub async fn bind(&self, address: SocketAddr) -> Result<(), Error>
pub async fn bind(&self, address: SocketAddr) -> Result<(), Error>
Bind the socket to a given address.
This calls the nrfxlib_sys::nrf_bind function and can be used for UDP sockets.
Sourcepub async unsafe fn bind_with_cancellation(
&self,
address: SocketAddr,
token: &CancellationToken,
) -> Result<(), Error>
pub async unsafe fn bind_with_cancellation( &self, address: SocketAddr, token: &CancellationToken, ) -> Result<(), Error>
Bind the socket to a given address.
This calls the nrfxlib_sys::nrf_bind function and can be used for UDP sockets.
§Safety
If the bind is cancelled, the socket may be in a weird state and should be dropped.
Sourcepub async fn write(&self, buffer: &[u8]) -> Result<usize, Error>
pub async fn write(&self, buffer: &[u8]) -> Result<usize, Error>
Write data to the socket.
This calls the nrfxlib_sys::nrf_send function and can be used for TCP streams and dTLS connections.
Sourcepub async fn write_with_cancellation(
&self,
buffer: &[u8],
token: &CancellationToken,
) -> Result<usize, Error>
pub async fn write_with_cancellation( &self, buffer: &[u8], token: &CancellationToken, ) -> Result<usize, Error>
Write data to the socket with cancellation support.
This calls the nrfxlib_sys::nrf_send function and can be used for TCP streams and dTLS connections.
This operation can be cancelled using the provided CancellationToken.
Sourcepub async fn receive(&self, buffer: &mut [u8]) -> Result<usize, Error>
pub async fn receive(&self, buffer: &mut [u8]) -> Result<usize, Error>
Receive data from the socket.
This calls the nrfxlib_sys::nrf_recv function and can be used for TCP streams and dTLS connections.
Sourcepub async fn receive_with_cancellation(
&self,
buffer: &mut [u8],
token: &CancellationToken,
) -> Result<usize, Error>
pub async fn receive_with_cancellation( &self, buffer: &mut [u8], token: &CancellationToken, ) -> Result<usize, Error>
Receive data from the socket with cancellation support.
This calls the nrfxlib_sys::nrf_recv function and can be used for TCP streams and dTLS connections.
This operation can be cancelled using the provided CancellationToken.
Sourcepub async fn receive_from(
&self,
buffer: &mut [u8],
) -> Result<(usize, SocketAddr), Error>
pub async fn receive_from( &self, buffer: &mut [u8], ) -> Result<(usize, SocketAddr), Error>
Receive data from the socket along with the sender’s address.
This calls the nrfxlib_sys::nrf_recvfrom function and can be used for UDP sockets.
Sourcepub async fn receive_from_with_cancellation(
&self,
buffer: &mut [u8],
token: &CancellationToken,
) -> Result<(usize, SocketAddr), Error>
pub async fn receive_from_with_cancellation( &self, buffer: &mut [u8], token: &CancellationToken, ) -> Result<(usize, SocketAddr), Error>
Receive data from the socket along with the sender’s address, with cancellation support.
This calls the nrfxlib_sys::nrf_recvfrom function and can be used for UDP sockets.
This operation can be cancelled using the provided CancellationToken.
Sourcepub async fn send_to(
&self,
buffer: &[u8],
address: SocketAddr,
) -> Result<usize, Error>
pub async fn send_to( &self, buffer: &[u8], address: SocketAddr, ) -> Result<usize, Error>
Send data to a specific address through the socket.
This calls the nrfxlib_sys::nrf_sendto function and can be used for UDP sockets.
Sourcepub async fn send_to_with_cancellation(
&self,
buffer: &[u8],
address: SocketAddr,
token: &CancellationToken,
) -> Result<usize, Error>
pub async fn send_to_with_cancellation( &self, buffer: &[u8], address: SocketAddr, token: &CancellationToken, ) -> Result<usize, Error>
Send data to a specific address through the socket with cancellation support.
This calls the nrfxlib_sys::nrf_sendto function and can be used for UDP sockets.
This operation can be cancelled using the provided CancellationToken.
Sourcepub fn set_option<'a>(
&'a self,
option: SocketOption<'a>,
) -> Result<(), SocketOptionError>
pub fn set_option<'a>( &'a self, option: SocketOption<'a>, ) -> Result<(), SocketOptionError>
Set a socket option.
This calls the nrfxlib_sys::nrf_setsockopt function and provides access to various socket configuration options including timeouts, TLS settings, PDN binding, and protocol-specific options.
See SocketOption for available options.