Function tokio_tungstenite::accept_async
source · [−]pub async fn accept_async<S>(stream: S) -> Result<WebSocketStream<S>, WsError> where
S: AsyncRead + AsyncWrite + Unpin,
Expand description
Accepts a new WebSocket connection with the provided stream.
This function will internally call server::accept
to create a
handshake representation and returns a future representing the
resolution of the WebSocket handshake. The returned future will resolve
to either WebSocketStream<S>
or Error
depending if it’s successful
or not.
This is typically used after a socket has been accepted from a
TcpListener
. That socket is then passed to this function to perform
the server half of the accepting a client’s websocket connection.