Struct unix_udp_sock::sync::UdpSocket

source ·
pub struct UdpSocket { /* private fields */ }

Implementations§

source§

impl UdpSocket

source

pub fn from_std(socket: UdpSocket) -> Result<Self>

Creates a new UDP socket from a previously created std::net::UdpSocket

source

pub fn bind<A: ToSocketAddrs>(addr: A) -> Result<Self>

create a new UDP socket and attempt to bind to addr

source

pub fn set_nonblocking(&self, nonblocking: bool) -> Result<()>

sets nonblocking mode

source

pub fn set_broadcast(&self, broadcast: bool) -> Result<()>

sets the value of SO_BROADCAST for this socket

source

pub fn connect<A: ToSocketAddrs>(&self, addrs: A) -> Result<()>

source

pub fn join_multicast_v4( &self, multiaddr: Ipv4Addr, interface: Ipv4Addr, ) -> Result<()>

source

pub fn join_multicast_v6( &self, multiaddr: &Ipv6Addr, interface: u32, ) -> Result<()>

source

pub fn leave_multicast_v4( &self, multiaddr: Ipv4Addr, interface: Ipv4Addr, ) -> Result<()>

source

pub fn leave_multicast_v6( &self, multiaddr: &Ipv6Addr, interface: u32, ) -> Result<()>

source

pub fn set_multicast_loop_v4(&self, on: bool) -> Result<()>

source

pub fn set_multicast_loop_v6(&self, on: bool) -> Result<()>

source

pub fn send_to(&self, buf: &[u8], target: SocketAddr) -> Result<usize>

Sends data on the socket to the given address. On success, returns the number of bytes written.

calls underlying tokio send_to

source

pub fn send(&self, buf: &[u8]) -> Result<usize>

Sends data on the socket to the remote address that the socket is connected to.

See tokio send

source

pub fn recv_from(&self, buf: &mut [u8]) -> Result<(usize, SocketAddr)>

Receives a single datagram message on the socket. On success, returns the number of bytes read and the origin.

See tokio recv_from

source

pub fn recv(&self, buf: &mut [u8]) -> Result<usize>

Receives a single datagram message on the socket from the remote address to which it is connected. On success, returns the number of bytes read.

See tokio recv

source

pub fn send_mmsg<B: AsPtr<u8>>( &mut self, state: &UdpState, transmits: &[Transmit<B>], ) -> Result<usize, Error>

Calls syscall sendmmsg. With a given state configured GSO and transmits with information on the data and metadata about outgoing packets.

source

pub fn send_msg<B: AsPtr<u8>>( &self, state: &UdpState, transmits: Transmit<B>, ) -> Result<usize>

Calls syscall sendmsg. With a given state configured GSO and transmit with information on the data and metadata about outgoing packet.

source

pub fn recv_mmsg( &self, bufs: &mut [IoSliceMut<'_>], meta: &mut [RecvMeta], ) -> Result<usize>

async version of recvmmsg

source

pub fn recv_msg(&self, buf: &mut [u8]) -> Result<RecvMeta>

recv_msg is similar to recv_from but returns extra information about the packet in RecvMeta.

source

pub fn local_addr(&self) -> Result<SocketAddr>

Returns local address this socket is bound to.

Trait Implementations§

source§

impl AsRawFd for UdpSocket

source§

fn as_raw_fd(&self) -> RawFd

Extracts the raw file descriptor. Read more
source§

impl Debug for UdpSocket

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl IntoRawFd for UdpSocket

source§

fn into_raw_fd(self) -> RawFd

Consumes this object, returning the raw underlying file descriptor. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more