[][src]Struct libuv::handles::streams::udp::UdpHandle

pub struct UdpHandle { /* fields omitted */ }

UDP handles encapsulate UDP communication for both clients and servers.

Implementations

impl UdpHandle[src]

pub fn new(r#loop: &Loop) -> Result<UdpHandle>[src]

Initialize a new UDP handle. The actual socket is created lazily.

pub fn new_ex(r#loop: &Loop, flags: UdpFlags) -> Result<UdpHandle>[src]

Initialize the handle with the specified flags. A socket will be created for the given domain. If the specified domain is AF_UNSPEC no socket is created, just like new().

pub fn bind(
    &mut self,
    addr: &SocketAddr,
    flags: UdpBindFlags
) -> Result<(), Box<dyn Error>>
[src]

Bind the UDP handle to an IP address and port.

pub fn connect(
    &mut self,
    addr: Option<&SocketAddr>
) -> Result<(), Box<dyn Error>>
[src]

Associate the UDP handle to a remote address and port, so every message sent by this handle is automatically sent to that destination. Calling this function with a None addr disconnects the handle. Trying to call connect() on an already connected handle will result in an EISCONN error. Trying to disconnect a handle that is not connected will return an ENOTCONN error.

pub fn getpeername(&self) -> Result<SocketAddr, Box<dyn Error>>[src]

Get the remote IP and port of the UDP handle on connected UDP handles. On unconnected handles, it returns ENOTCONN.

pub fn getsockname(&self) -> Result<SocketAddr, Box<dyn Error>>[src]

Get the local IP and port of the UDP handle.

pub fn set_membership(
    &mut self,
    multicast_addr: &str,
    interface_addr: &str,
    membership: Membership
) -> Result<(), Box<dyn Error>>
[src]

Set membership for a multicast address

pub fn set_source_membership(
    &mut self,
    multicast_addr: &str,
    interface_addr: &str,
    source_addr: &str,
    membership: Membership
) -> Result<(), Box<dyn Error>>
[src]

Set membership for a source-specific multicast group.

pub fn set_multicast_loop(&mut self, enable: bool) -> Result<()>[src]

Set IP multicast loop flag. Makes multicast packets loop back to local sockets.

pub fn set_multicast_ttl(&mut self, ttl: i32) -> Result<()>[src]

Set the multicast ttl.

pub fn set_multicast_interface(
    &mut self,
    interface_addr: &str
) -> Result<(), Box<dyn Error>>
[src]

Set the multicast interface to send or receive data on.

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

Set broadcast on or off.

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

Set the time to live.

pub fn send<CB: Into<UdpSendCB<'static>>>(
    &self,
    addr: Option<&SocketAddr>,
    bufs: &[impl BufTrait],
    cb: CB
) -> Result<UdpSendReq, Box<dyn Error>>
[src]

Send data over the UDP socket. If the socket has not previously been bound with bind() it will be bound to 0.0.0.0 (the “all interfaces” IPv4 address) and a random port number.

On Windows if the addr is initialized to point to an unspecified address (0.0.0.0 or ::) it will be changed to point to localhost. This is done to match the behavior of Linux systems.

For connected UDP handles, addr must be set to None, otherwise it will return EISCONN error.

For connectionless UDP handles, addr cannot be None, otherwise it will return EDESTADDRREQ error.

pub fn try_send(
    &self,
    addr: Option<&SocketAddr>,
    bufs: &[impl BufTrait]
) -> Result<i32, Box<dyn Error>>
[src]

Same as send(), but won’t queue a send request if it can’t be completed immediately.

For connected UDP handles, addr must be set to None, otherwise it will return EISCONN error.

For connectionless UDP handles, addr cannot be None, otherwise it will return EDESTADDRREQ error.

pub fn recv_start<ACB: Into<AllocCB<'static>>, CB: Into<RecvCB<'static>>>(
    &mut self,
    alloc_cb: ACB,
    recv_cb: CB
) -> Result<()>
[src]

Prepare for receiving data. If the socket has not previously been bound with bind() it is bound to 0.0.0.0 (the “all interfaces” IPv4 address) and a random port number.

pub fn recv_stop(&mut self) -> Result<()>[src]

Stop listening for incoming datagrams.

pub fn get_send_queue_size(&self) -> usize[src]

Returns the size of the send queue

pub fn get_send_queue_count(&self) -> usize[src]

Returns the count of the send queue

Trait Implementations

impl Clone for UdpHandle[src]

impl Copy for UdpHandle[src]

impl From<UdpHandle> for StreamHandle[src]

impl From<UdpHandle> for Handle[src]

impl HandleTrait for UdpHandle[src]

impl StreamTrait for UdpHandle[src]

impl ToHandle for UdpHandle[src]

impl ToStream for UdpHandle[src]

impl TryFrom<Handle> for UdpHandle[src]

type Error = ConversionError

The type returned in the event of a conversion error.

impl TryFrom<StreamHandle> for UdpHandle[src]

type Error = ConversionError

The type returned in the event of a conversion error.

Auto Trait Implementations

Blanket Implementations

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

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

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

impl<T> From<T> for T[src]

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

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

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

type Error = Infallible

The type returned in the event of a conversion error.

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

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

The type returned in the event of a conversion error.