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
sourceimpl UdpBuilder
impl UdpBuilder
sourcepub fn new_v4() -> Result<UdpBuilder>
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.
sourcepub fn new_v6() -> Result<UdpBuilder>
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.
sourcepub fn bind<T>(&self, addr: T) -> Result<UdpSocket> where
T: ToSocketAddrs,
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.
sourceimpl UdpBuilder
impl UdpBuilder
sourcepub fn ttl(&self, ttl: u32) -> Result<&Self>
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
.
sourcepub fn only_v6(&self, only_v6: bool) -> Result<&Self>
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
.
sourcepub fn reuse_address(&self, reuse: bool) -> Result<&Self>
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
.
sourcepub fn get_reuse_address(&self) -> Result<bool>
pub fn get_reuse_address(&self) -> Result<bool>
Check the SO_REUSEADDR
option on this socket.
sourcepub fn take_error(&self) -> Result<Option<Error>>
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
sourceimpl AsRawFd for UdpBuilder
impl AsRawFd for UdpBuilder
sourceimpl Debug for UdpBuilder
impl Debug for UdpBuilder
sourceimpl FromRawFd for UdpBuilder
impl FromRawFd for UdpBuilder
sourceunsafe fn from_raw_fd(fd: c_int) -> UdpBuilder
unsafe fn from_raw_fd(fd: c_int) -> UdpBuilder
Constructs a new instance of Self
from the given raw file
descriptor. Read more
sourceimpl UnixUdpBuilderExt for UdpBuilder
impl UnixUdpBuilderExt for UdpBuilder
sourcefn reuse_port(&self, reuse: bool) -> Result<&Self>
fn reuse_port(&self, reuse: bool) -> Result<&Self>
Set value for the SO_REUSEPORT
option on this socket. Read more
sourcefn get_reuse_port(&self) -> Result<bool>
fn get_reuse_port(&self) -> Result<bool>
Check the value of the SO_REUSEPORT
option on this socket.
Auto Trait Implementations
impl !RefUnwindSafe for UdpBuilder
impl Send for UdpBuilder
impl !Sync for UdpBuilder
impl Unpin for UdpBuilder
impl UnwindSafe for UdpBuilder
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more