[][src]Struct cancellable_io::UdpSocket

pub struct UdpSocket { /* fields omitted */ }

An UDP socket bound to an address.

The recv_from, send_to, recv, and send can be interrupted using the Canceller object created with the socket.

Otherwise similar to std::net::UdpSocket.

Methods

impl UdpSocket[src]

pub fn bind<A: ToSocketAddrs>(address: A) -> Result<(Self, Canceller)>[src]

Creates an UDP socket from the given address, together with an object that can be used to cancel send/recv operations.

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

Receives a single datagram message from the socket.

This method can be cancelled by the associated Canceller object.

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

Sends a single datagram message to the given address.

This method can be cancelled by the associated Canceller object.

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

Gets the socket address that this object was created from.

pub fn try_clone(&self) -> Result<(Self, Canceller)>[src]

Creates a new independently owned handle to the underlying socket.

pub fn set_read_timeout(&self, duration: Option<Duration>) -> Result<()>[src]

Sets the read timeout to the timeout specified.

pub fn set_write_timeout(&self, duration: Option<Duration>) -> Result<()>[src]

Sets the write timeout to the timeout specified.

pub fn read_timeout(&self) -> Result<Option<Duration>>[src]

Returns the read timeout of this socket.

pub fn write_timeout(&self) -> Result<Option<Duration>>[src]

Returns the write timeout of this socket.

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

Sets the value of the SO_BROADCAST option for this socket.

pub fn broadcast(&self) -> Result<bool>[src]

Gets the value of the SO_BROADCAST option for this socket.

pub fn set_multicast_loop_v4(&self, multicast_loop: bool) -> Result<()>[src]

Sets the value of the IP_MULTICAST_LOOP option for this socket.

pub fn multicast_loop_v4(&self) -> Result<bool>[src]

Gets the value of the IP_MULTICAST_LOOP option for this socket.

pub fn set_multicast_ttl_v4(&self, multicast_ttl: u32) -> Result<()>[src]

Sets the value of the IP_MULTICAST_TTL option for this socket.

pub fn multicast_ttl_v4(&self) -> Result<u32>[src]

Gets the value of the IP_MULTICAST_TTL option for this socket.

pub fn set_multicast_loop_v6(&self, multicast_loop: bool) -> Result<()>[src]

Sets the value of the IPV6_MULTICAST_LOOP option for this socket.

pub fn multicast_loop_v6(&self) -> Result<bool>[src]

Gets the value of the IPV6_MULTICAST_LOOP option for this socket.

pub fn set_ttl(&self, ttl: u32) -> Result<()>[src]

Sets the value for the IP_TTL option on this socket.

pub fn ttl(&self) -> Result<u32>[src]

Gets the value for the IP_TTL option for this socket.

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

Executes an operation of the IP_ADD_MEMBERSHIP type.

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

Executes an operation of the IPV6_ADD_MEMBERSHIP type.

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

Executes an operation of the IP_DROP_MEMBERSHIP type.

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

Executes an operation of the IPV6_DROP_MEMBERSHIP type.

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

Gets the value of the SO_ERROR option for this socket.

pub fn set_only_v6(&self, only_v6: bool) -> Result<()>[src]

Sets the value for the IPV6_V6ONLY option on this socket.

pub fn only_v6(&self) -> Result<bool>[src]

Gets the value for the IPV6_V6ONLY option for this socket.

pub fn connect<A: ToSocketAddrs>(&self, address: A) -> Result<()>[src]

Connects this socket to a remote address.

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

Moves this socket into or out of non blocking mode.

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

Receives a single datagram from the connected remote address.

This method can be cancelled by the associated Canceller object.

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

Sends a single datagram to the connected remote address.

This method can be cancelled by the associated Canceller object.

Trait Implementations

impl Debug for UdpSocket[src]

Auto Trait Implementations

impl Send for UdpSocket

impl !Sync for UdpSocket

Blanket Implementations

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> From for T[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.