listen

Function listen 

Source
pub fn listen(port: u16) -> Listener
Expand description

Start a listener on the given port.

ยงPanics

If the current port is already being listened on by another listener.

Examples found in repository?
examples/broadcast.rs (line 99)
98async fn listen_for_connections(n: usize, state: NodeStateRef) {
99    let mut listener = api::listen(80);
100    while let Some(conn) = listener.accept().await {
101        if n == *conn.remote() {
102            api::spawn(handle_client_connection(state.clone(), conn));
103        } else {
104            api::spawn(handle_connection(state.clone(), conn));
105        }
106    }
107}