pub struct Listener { /* private fields */ }Expand description
Listens for incoming WebSocket connections on a TCP port.
Use with crate::Server::with_websocket to accept WebSocket connections
alongside QUIC connections on a separate port.
Implementations§
Source§impl Listener
impl Listener
Sourcepub async fn bind(addr: SocketAddr) -> Result<Self, Error>
pub async fn bind(addr: SocketAddr) -> Result<Self, Error>
Bind a listener to the given address, accepting every moq ALPN we know about.
Sourcepub async fn bind_with_alpns(
addr: SocketAddr,
alpns: &[&str],
) -> Result<Self, Error>
pub async fn bind_with_alpns( addr: SocketAddr, alpns: &[&str], ) -> Result<Self, Error>
Bind a listener that only accepts the given moq ALPNs, in preference order.
Sourcepub fn local_addr(&self) -> Result<SocketAddr, Error>
pub fn local_addr(&self) -> Result<SocketAddr, Error>
The local address the listener is bound to.
Sourcepub fn accept_health(&self) -> Health
pub fn accept_health(&self) -> Health
A live handle to this listener’s accept-loop health, for an embedder that
publishes it (see crate::accept).
Sourcepub async fn accept(&self) -> Option<Result<Session, Error>>
pub async fn accept(&self) -> Option<Result<Session, Error>>
Accept the next connection, performing the WebSocket upgrade and qmux handshake.
A failed accept(2) is handled here rather than yielded: it is classified,
counted, logged, and paced by accept_health, then
retried, because the caller has no better answer than to ask again. A
per-connection upgrade failure is still yielded as Some(Err(..)).
As in crate::tcp, the Option has no None case left to report.