Struct holochain_websocket::WebsocketListener

source ·
pub struct WebsocketListener { /* private fields */ }
Expand description

A Holochain websocket listener.

Implementations§

source§

impl WebsocketListener

source

pub async fn bind( config: Arc<WebsocketConfig>, addr: impl ToSocketAddrs ) -> Result<Self>

Bind a new websocket listener.

source

pub async fn dual_bind( config: Arc<WebsocketConfig>, addr_v4: SocketAddrV4, addr_v6: SocketAddrV6 ) -> Result<Self>

Bind a new websocket listener on the same port using a v4 and a v6 socket.

If the port is 0, then the OS will be allowed to pick a port for IPv6. This function will then try to bind to the same port for IPv4. If the OS picks a port that is not available for IPv4, then the function will retry binding IPv6 to get a new port and see if that is available for IPv4. If this fails after 5 retries, then an error will be returned.

If either IPv4 or IPv6 is disabled, then the function will fall back to binding to the available stack. An info message will be logged to let the user know that one interface was unavailable, but this is likely intentional or expected in the user’s environment, so it will not be treated as an error that should prevent the listener from starting.

Note: The interface fallback behaviour can be tested manually on Linux by running: echo 1 | sudo tee /proc/sys/net/ipv6/conf/lo/disable_ipv6 and then trying to start Holochain with info logging enabled. You can undo the change with: echo 0 | sudo tee /proc/sys/net/ipv6/conf/lo/disable_ipv6.

source

pub fn local_addrs(&self) -> Result<Vec<SocketAddr>>

Get the bound local address of this listener.

source

pub async fn accept(&self) -> Result<(WebsocketSender, WebsocketReceiver)>

Accept an incoming connection.

Trait Implementations§

source§

impl Drop for WebsocketListener

source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

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

source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more