pub struct UdpSocketState { /* private fields */ }
Expand description
Tokio-compatible UDP socket with some useful specializations.
Unlike a standard tokio UDP socket, this allows ECN bits to be read and written on some platforms.
Implementations§
Source§impl UdpSocketState
impl UdpSocketState
pub fn new(sock: UdpSockRef<'_>) -> Result<Self>
Sourcepub fn send(
&self,
socket: UdpSockRef<'_>,
transmit: &Transmit<'_>,
) -> Result<()>
pub fn send( &self, socket: UdpSockRef<'_>, transmit: &Transmit<'_>, ) -> Result<()>
Sends a Transmit
on the given socket.
This function will only ever return errors of kind io::ErrorKind::WouldBlock
.
All other errors will be logged and converted to Ok
.
UDP transmission errors are considered non-fatal because higher-level protocols must employ retransmits and timeouts anyway in order to deal with UDP’s unreliable nature. Thus, logging is most likely the only thing you can do with these errors.
If you would like to handle these errors yourself, use UdpSocketState::try_send
instead.
Sourcepub fn try_send(
&self,
socket: UdpSockRef<'_>,
transmit: &Transmit<'_>,
) -> Result<()>
pub fn try_send( &self, socket: UdpSockRef<'_>, transmit: &Transmit<'_>, ) -> Result<()>
Sends a Transmit
on the given socket without any additional error handling.
pub fn recv( &self, socket: UdpSockRef<'_>, bufs: &mut [IoSliceMut<'_>], meta: &mut [RecvMeta], ) -> Result<usize>
Sourcepub fn max_gso_segments(&self) -> usize
pub fn max_gso_segments(&self) -> usize
The maximum amount of segments which can be transmitted if a platform supports Generic Send Offload (GSO).
This is 1 if the platform doesn’t support GSO. Subject to change if errors are detected while using GSO.
Sourcepub fn gro_segments(&self) -> usize
pub fn gro_segments(&self) -> usize
The number of segments to read when GRO is enabled. Used as a factor to compute the receive buffer size.
Returns 1 if the platform doesn’t support GRO.
Sourcepub fn may_fragment(&self) -> bool
pub fn may_fragment(&self) -> bool
Whether transmitted datagrams might get fragmented by the IP layer
Returns false
on targets which employ e.g. the IPV6_DONTFRAG
socket option.