Struct net2::UdpBuilder

source ·
pub struct UdpBuilder { /* private fields */ }
Expand description

An “in progress” UDP socket which has not yet been connected.

Allows configuration of a socket before the socket is connected.

Implementations§

source§

impl UdpBuilder

source

pub fn new_v4() -> Result<UdpBuilder>

Constructs a new UdpBuilder with the AF_INET domain, the SOCK_DGRAM type, and with a protocol argument of 0.

Note that passing other kinds of flags or arguments can be done through the FromRaw{Fd,Socket} implementation.

source

pub fn new_v6() -> Result<UdpBuilder>

Constructs a new UdpBuilder with the AF_INET6 domain, the SOCK_DGRAM type, and with a protocol argument of 0.

Note that passing other kinds of flags or arguments can be done through the FromRaw{Fd,Socket} implementation.

source

pub fn bind<T>(&self, addr: T) -> Result<UdpSocket>where T: ToSocketAddrs,

Binds this socket to the specified address.

This function directly corresponds to the bind(2) function on Windows and Unix.

source§

impl UdpBuilder

source

pub fn ttl(&self, ttl: u32) -> Result<&Self>

Sets the value for the IP_TTL option on this socket.

This is the same as TcpStreamExt::set_ttl.

source

pub fn only_v6(&self, only_v6: bool) -> Result<&Self>

Sets the value for the IPV6_V6ONLY option on this socket.

This is the same as TcpStream::only_v6.

source

pub fn reuse_address(&self, reuse: bool) -> Result<&Self>

Set value for the SO_REUSEADDR option on this socket.

This is the same as TcpBuilder::reuse_address.

source

pub fn get_reuse_address(&self) -> Result<bool>

Check the SO_REUSEADDR option on this socket.

source

pub fn take_error(&self) -> Result<Option<Error>>

Get the value of the SO_ERROR option on this socket.

This will retrieve the stored error in the underlying socket, clearing the field in the process. This can be useful for checking errors between calls.

Trait Implementations§

source§

impl AsRawFd for UdpBuilder

source§

fn as_raw_fd(&self) -> c_int

Extracts the raw file descriptor. Read more
source§

impl Debug for UdpBuilder

source§

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

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

impl FromRawFd for UdpBuilder

source§

unsafe fn from_raw_fd(fd: c_int) -> UdpBuilder

Constructs a new instance of Self from the given raw file descriptor. Read more
source§

impl UnixUdpBuilderExt for UdpBuilder

source§

fn reuse_port(&self, reuse: bool) -> Result<&Self>

Set value for the SO_REUSEPORT option on this socket. Read more
source§

fn get_reuse_port(&self) -> Result<bool>

Check the value of the SO_REUSEPORT option on this socket.

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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, U> Into<U> for Twhere 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 Twhere 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 Twhere 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.