pub struct UdpListener { /* private fields */ }

Implementations

An I/O object representing a UDP socket listening for incoming connections.

This object can be converted into a stream of incoming connections for various forms of processing.

Examples

use udp_stream::UdpListener;

use std::{io, net::SocketAddr};

#[tokio::main]
async fn main() -> io::Result<()> {
    let mut listener = UdpListener::bind(SocketAddr::from_str("127.0.0.1:8080").unwrap()).await?;

    loop {
        let (socket, _) = listener.accept().await?;
        process_socket(socket).await;
    }
}

Returns the local address that this socket is bound to.

Trait Implementations

Executes the destructor for this type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.