pub struct WsListener { /* private fields */ }Expand description
Listening endpoint for inbound WebSocket connections.
Holding this alive keeps the bound TCP socket open; dropping it closes the socket (the OS releases the port).
Implementations§
Source§impl WsListener
impl WsListener
Sourcepub fn bind(scheme: &str, host: &str, port: u16) -> Result<Self>
pub fn bind(scheme: &str, host: &str, port: u16) -> Result<Self>
Bind a new listener at host:port. The address family is
always IPv4 (matching the loopback test pattern used by
confium-net-tcp); pass 0.0.0.0 for any interface or
127.0.0.1 for loopback-only. Passing port 0 requests an
ephemeral port from the OS; the caller can read the assigned
port back via local_addr.
Sourcepub fn local_addr(&self) -> Result<SocketAddr>
pub fn local_addr(&self) -> Result<SocketAddr>
The locally-bound socket address. Useful for reading back the
OS-assigned ephemeral port after binding with port 0.
Trait Implementations§
Source§impl Drop for WsListener
impl Drop for WsListener
Auto Trait Implementations§
impl Freeze for WsListener
impl RefUnwindSafe for WsListener
impl Send for WsListener
impl Sync for WsListener
impl Unpin for WsListener
impl UnsafeUnpin for WsListener
impl UnwindSafe for WsListener
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more