Skip to main content

tcp_listener

Function tcp_listener 

Source
pub fn tcp_listener(sock: TcpListener) -> Result<Listener, Error>
Expand description

Registers a TCP listener with the current reactor.

The socket must be bound, listening and in non-blocking mode; set it with net::TcpListener::set_nonblocking. A blocking socket stalls the runtime thread in Listener::accept.

Only the native polling and io-uring reactors support listeners. The Tokio, Compio and IOCP reactors return an io::ErrorKind::Unsupported error. The socket is closed on error.

ยงPanics

Panics if called outside an ntex runtime, for example from a plain thread or a runtime from another crate. Call it from code running under #[ntex::main], #[ntex::test], or an ntex System.