[−][src]Struct fumio::net::UdpSocket
A UDP socket
Methods
impl UdpSocket
[src]
pub fn default_builder_for(local: &SocketAddr) -> Result<UdpBuilder, Error>
[src]
Create builder with default options, but doesn't bind yet.
To create a UdpSocket
from a builder go through the std::net::UdpSocket
created by
builder.bind(...)?
.
pub fn from_std(
stream: UdpSocket,
handle: LazyHandle
) -> Result<UdpSocket, Error>
[src]
stream: UdpSocket,
handle: LazyHandle
) -> Result<UdpSocket, Error>
Wraps an already bound tcp stream
pub fn from_mio(
stream: UdpSocket,
handle: LazyHandle
) -> Result<UdpSocket, Error>
[src]
stream: UdpSocket,
handle: LazyHandle
) -> Result<UdpSocket, Error>
Wraps an already bound tcp stream
pub fn bind_port(port: u16) -> Result<UdpSocket, Error>
[src]
Binds a new UDP socket to IPv6 [::]
with V6_ONLY=false (i.e. also listen on IPv4) and the
given port.
If the port is 0 the OS will select a random port.
pub fn bind_ipv4_port(port: u16) -> Result<UdpSocket, Error>
[src]
Binds a new UDP socket to IPv4 0.0.0.0
and the given port.
If the port is 0 the OS will select a random port.
pub fn bind(local: SocketAddr) -> Result<UdpSocket, Error>
[src]
Bind a new UDP socket to the specified address.
pub fn bind_with(
local: SocketAddr,
handle: LazyHandle
) -> Result<UdpSocket, Error>
[src]
local: SocketAddr,
handle: LazyHandle
) -> Result<UdpSocket, Error>
Bind a new UDP socket to the specified address.
pub fn local_addr(&self) -> Result<SocketAddr, Error>
[src]
Returns the local socket address of this socket.
pub fn try_clone(&self) -> Result<UdpSocket, Error>
[src]
Creates a new independently owned handle to the underlying socket.
The new listener isn't registered to a reactor yet.
pub fn try_clone_with(&self, handle: LazyHandle) -> Result<UdpSocket, Error>
[src]
Creates a new independently owned handle to the underlying socket.
pub fn poll_recv_from(
&mut self,
cx: &mut Context,
buf: &mut [u8]
) -> Poll<Result<(usize, SocketAddr), Error>>
[src]
&mut self,
cx: &mut Context,
buf: &mut [u8]
) -> Poll<Result<(usize, SocketAddr), Error>>
Receives data from the socket. On success, returns the number of bytes read and the address from whence the data came.
ⓘImportant traits for UdpRecvFrom<'_>pub fn recv_from(&'a mut self, buf: &'a mut [u8]) -> UdpRecvFrom<'a>
[src]
Receives data from the socket. On success, completes with the number of bytes read and the address from whence the data came.
pub fn poll_send_to(
&mut self,
cx: &mut Context,
buf: &[u8],
target: &SocketAddr
) -> Poll<Result<usize, Error>>
[src]
&mut self,
cx: &mut Context,
buf: &[u8],
target: &SocketAddr
) -> Poll<Result<usize, Error>>
Sends data on the socket to the given address. On success, returns the number of bytes written.
ⓘImportant traits for UdpSendTo<'_>pub fn send_to(
&'a mut self,
buf: &'a [u8],
target: &'a SocketAddr
) -> UdpSendTo<'a>
[src]
&'a mut self,
buf: &'a [u8],
target: &'a SocketAddr
) -> UdpSendTo<'a>
Sends data on the socket to the given address. On success, completes with the number of bytes written.
pub fn set_broadcast(&self, on: bool) -> Result<(), Error>
[src]
Sets the value of the SO_BROADCAST
option for this socket.
When enabled, this socket is allowed to send packets to a broadcast address.
pub fn broadcast(&self) -> Result<bool, Error>
[src]
Gets the value of the SO_BROADCAST option for this socket.
For more information about this option, see set_broadcast.
pub fn set_multicast_loop_v4(&self, on: bool) -> Result<(), Error>
[src]
Sets the value of the IP_MULTICAST_LOOP
option for this socket.
If enabled, multicast packets will be looped back to the local socket. Note that this may not have any affect on IPv6 sockets.
pub fn multicast_loop_v4(&self) -> Result<bool, Error>
[src]
Gets the value of the IP_MULTICAST_LOOP
option for this socket.
For more information about this option, see
set_multicast_loop_v4
.
pub fn set_multicast_ttl_v4(&self, ttl: u32) -> Result<(), Error>
[src]
Sets the value of the IP_MULTICAST_TTL
option for this socket.
Indicates the time-to-live value of outgoing multicast packets for this socket. The default value is 1 which means that multicast packets don't leave the local network unless explicitly requested.
Note that this may not have any affect on IPv6 sockets.
pub fn multicast_ttl_v4(&self) -> Result<u32, Error>
[src]
Gets the value of the IP_MULTICAST_TTL
option for this socket.
For more information about this option, see
set_multicast_ttl_v4
.
pub fn set_multicast_loop_v6(&self, on: bool) -> Result<(), Error>
[src]
Sets the value of the IPV6_MULTICAST_LOOP
option for this socket.
Controls whether this socket sees the multicast packets it sends itself. Note that this may not have any affect on IPv4 sockets.
pub fn multicast_loop_v6(&self) -> Result<bool, Error>
[src]
Gets the value of the IPV6_MULTICAST_LOOP
option for this socket.
For more information about this option, see
set_multicast_loop_v6
.
pub fn set_ttl(&self, ttl: u32) -> Result<(), Error>
[src]
Sets the value for the IP_TTL
option on this socket.
This value sets the time-to-live field that is used in every packet sent from this socket.
pub fn ttl(&self) -> Result<u32, Error>
[src]
Gets the value of the IP_TTL
option for this socket.
For more information about this option, see set_ttl
.
pub fn join_multicast_v4(
&self,
multiaddr: Ipv4Addr,
interface: Ipv4Addr
) -> Result<(), Error>
[src]
&self,
multiaddr: Ipv4Addr,
interface: Ipv4Addr
) -> Result<(), Error>
Executes an operation of the IP_ADD_MEMBERSHIP
type.
This function specifies a new multicast group for this socket to join.
The address must be a valid multicast address, and interface
is the
address of the local interface with which the system should join the
multicast group. If it's equal to INADDR_ANY
then an appropriate
interface is chosen by the system.
pub fn join_multicast_v6(
&self,
multiaddr: Ipv6Addr,
interface: u32
) -> Result<(), Error>
[src]
&self,
multiaddr: Ipv6Addr,
interface: u32
) -> Result<(), Error>
Executes an operation of the IPV6_ADD_MEMBERSHIP
type.
This function specifies a new multicast group for this socket to join.
The address must be a valid multicast address, and interface
is the
index of the interface to join/leave (or 0 to indicate any interface).
pub fn leave_multicast_v4(
&self,
multiaddr: Ipv4Addr,
interface: Ipv4Addr
) -> Result<(), Error>
[src]
&self,
multiaddr: Ipv4Addr,
interface: Ipv4Addr
) -> Result<(), Error>
Executes an operation of the IP_DROP_MEMBERSHIP
type.
For more information about this option, see
join_multicast_v4
.
pub fn leave_multicast_v6(
&self,
multiaddr: Ipv6Addr,
interface: u32
) -> Result<(), Error>
[src]
&self,
multiaddr: Ipv6Addr,
interface: u32
) -> Result<(), Error>
Executes an operation of the IPV6_DROP_MEMBERSHIP
type.
For more information about this option, see
join_multicast_v6
.
pub fn take_error(&self) -> Result<Option<Error>, Error>
[src]
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
impl TryFrom<UdpSocket> for UdpSocket
[src]
type Error = Error
The type returned in the event of a conversion error.
fn try_from(s: UdpSocket) -> Result<UdpSocket, Error>
[src]
impl TryFrom<UdpSocket> for UdpSocket
[src]
type Error = Error
The type returned in the event of a conversion error.
fn try_from(s: UdpSocket) -> Result<UdpSocket, Error>
[src]
impl Debug for UdpSocket
[src]
Auto Trait Implementations
impl Send for UdpSocket
impl Unpin for UdpSocket
impl Sync for UdpSocket
impl !UnwindSafe for UdpSocket
impl !RefUnwindSafe for UdpSocket
Blanket Implementations
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
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>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
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> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,