Struct asio::ip::Udp [] [src]

pub struct Udp {
    // some fields omitted
}

The User Datagram Protocol.

Examples

In this example, Creates a UDP server socket with resolving.

use std::io;
use asio::{IoService, Protocol};
use asio::ip::{Udp, UdpSocket, UdpEndpoint, UdpResolver, ResolverIter, Passive};

fn udp_bind(io: &IoService, it: ResolverIter<Udp>) -> io::Result<UdpSocket> {
    for (ep, _) in it {
        println!("{:?}", ep);
        if let Ok(soc) = UdpSocket::new(io, ep.protocol()) {
            if let Ok(_) = soc.bind(&ep) {
                return Ok(soc)
            }
        }
    }
    Err(io::Error::new(io::ErrorKind::Other, "Failed to bind"))
}

let io = IoService::new();
let re = UdpResolver::new(&io);
let sv = re.resolve((Passive, 12345))
           .and_then(|it| udp_bind(&io, it))
           .unwrap();

Methods

impl Udp
[src]

fn v4() -> Udp

Represents a UDP for IPv4.

fn v6() -> Udp

Represents a UDP for IPv6.

Trait Implementations

impl Debug for Udp
[src]

fn fmt(&self, __arg_0: &mut Formatter) -> Result

Formats the value using the given formatter.

impl PartialEq for Udp
[src]

fn eq(&self, __arg_0: &Udp) -> bool

This method tests for self and other values to be equal, and is used by ==. Read more

fn ne(&self, __arg_0: &Udp) -> bool

This method tests for !=.

impl Eq for Udp
[src]

impl Clone for Udp
[src]

fn clone(&self) -> Udp

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)
1.0.0

Performs copy-assignment from source. Read more

impl Protocol for Udp
[src]

type Endpoint = IpEndpoint<Udp>

fn family_type(&self) -> i32

Returns a value suitable for passing as the domain argument.

fn socket_type(&self) -> i32

Returns a value suitable for passing as the type argument.

fn protocol_type(&self) -> i32

Returns a value suitable for passing as the protocol argument.

impl IpProtocol for Udp
[src]

fn v4() -> Self

fn v6() -> Self

fn is_v4(&self) -> bool

fn is_v6(&self) -> bool