[−][src]Struct libuv::handles::streams::udp::UdpHandle
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]
&mut self,
addr: &SocketAddr,
flags: UdpBindFlags
) -> Result<(), Box<dyn Error>>
Bind the UDP handle to an IP address and port.
pub fn connect(
&mut self,
addr: Option<&SocketAddr>
) -> Result<(), Box<dyn Error>>
[src]
&mut self,
addr: Option<&SocketAddr>
) -> Result<(), Box<dyn Error>>
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]
&mut self,
multicast_addr: &str,
interface_addr: &str,
membership: Membership
) -> Result<(), Box<dyn Error>>
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]
&mut self,
multicast_addr: &str,
interface_addr: &str,
source_addr: &str,
membership: Membership
) -> Result<(), Box<dyn Error>>
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]
&mut self,
interface_addr: &str
) -> Result<(), Box<dyn Error>>
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]
&self,
addr: Option<&SocketAddr>,
bufs: &[impl BufTrait],
cb: CB
) -> Result<UdpSendReq, Box<dyn Error>>
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]
&self,
addr: Option<&SocketAddr>,
bufs: &[impl BufTrait]
) -> Result<i32, Box<dyn Error>>
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]
&mut self,
alloc_cb: ACB,
recv_cb: CB
) -> Result<()>
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]
fn from(udp: UdpHandle) -> StreamHandle
[src]
impl From<UdpHandle> for Handle
[src]
impl HandleTrait for UdpHandle
[src]
fn is_active(&self) -> bool
[src]
fn is_closing(&self) -> bool
[src]
fn close<CB: Into<CloseCB<'static>>>(&mut self, cb: CB)
[src]
fn ref(&mut self)
[src]
fn unref(&mut self)
[src]
fn has_ref(&self) -> bool
[src]
fn send_buffer_size(&mut self, value: i32) -> Result<i32>
[src]
fn recv_buffer_size(&mut self, value: i32) -> Result<i32>
[src]
fn get_fileno(&self) -> Result<OsFile>
[src]
fn get_loop(&self) -> Loop
[src]
fn get_type(&self) -> HandleType
[src]
impl StreamTrait for UdpHandle
[src]
fn shutdown<CB: Into<ShutdownCB<'static>>>(
&mut self,
cb: CB
) -> Result<ShutdownReq>
[src]
&mut self,
cb: CB
) -> Result<ShutdownReq>
fn listen<CB: Into<ConnectionCB<'static>>>(
&mut self,
backlog: i32,
cb: CB
) -> Result<()>
[src]
&mut self,
backlog: i32,
cb: CB
) -> Result<()>
fn accept(&mut self, client: &mut StreamHandle) -> Result<()>
[src]
fn read_start<ACB: Into<AllocCB<'static>>, RCB: Into<ReadCB<'static>>>(
&mut self,
alloc_cb: ACB,
read_cb: RCB
) -> Result<()>
[src]
&mut self,
alloc_cb: ACB,
read_cb: RCB
) -> Result<()>
fn read_stop(&mut self) -> Result<()>
[src]
fn write<CB: Into<WriteCB<'static>>>(
&mut self,
bufs: &[impl BufTrait],
cb: CB
) -> Result<WriteReq>
[src]
&mut self,
bufs: &[impl BufTrait],
cb: CB
) -> Result<WriteReq>
fn write2<CB: Into<WriteCB<'static>>>(
&mut self,
send_handle: &StreamHandle,
bufs: &[impl BufTrait],
cb: CB
) -> Result<WriteReq>
[src]
&mut self,
send_handle: &StreamHandle,
bufs: &[impl BufTrait],
cb: CB
) -> Result<WriteReq>
fn try_write(&mut self, bufs: &[impl BufTrait]) -> Result<i32>
[src]
fn is_readable(&self) -> bool
[src]
fn is_writable(&self) -> bool
[src]
fn set_blocking(&mut self, blocking: bool) -> Result<()>
[src]
fn get_write_queue_size(&self) -> usize
[src]
impl ToHandle for UdpHandle
[src]
impl ToStream for UdpHandle
[src]
fn to_stream(&self) -> StreamHandle
[src]
impl TryFrom<Handle> for UdpHandle
[src]
type Error = ConversionError
The type returned in the event of a conversion error.
fn try_from(handle: Handle) -> Result<Self, Self::Error>
[src]
impl TryFrom<StreamHandle> for UdpHandle
[src]
type Error = ConversionError
The type returned in the event of a conversion error.
fn try_from(stream: StreamHandle) -> Result<Self, Self::Error>
[src]
Auto Trait Implementations
impl RefUnwindSafe for UdpHandle
impl !Send for UdpHandle
impl !Sync for UdpHandle
impl Unpin for UdpHandle
impl UnwindSafe for UdpHandle
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,