websocket::Client
An owning WebSocket client — closes the connection (frame + TLS + socket) on destruction.
The RAII counterpart to the handle-based calls above. A Client owns one session; when it is destroyed (scope exit out of a with body, including via exception) or explicitly close()d, the close frame is sent and the TLS session and TCP socket are torn down, so with websocket.open_url(url) as ws { … } cannot leak the session, its tls session, or its fd. Move-only: the copy operations are deleted and a moved-from Client is left closed.
Functions
Client · 4 overloads
Construct a closed client (owns nothing).
operator= · 2 overloads
Move-assign, closing this session first, then taking over other's (which becomes closed).
other | the client to move from. |
reference to this client.
O(1).
none.
Close the connection if still open (close frame + TLS + socket teardown).
one TLS write + teardown.
a small close frame (when still open).
Is a connection open?
true iff this owns an open session.
O(1).
none.
The raw session handle (for the low-level calls).
the owned handle, or 0 when closed.
O(1).
none.
WebSocketSys.ClientGuardRoundTripReceive the next application message (see the free recv()).
the message payload; "" once the peer has closed.
std::runtime_error | on a transport/protocol error. |
O(message length).
the returned payload.
blocks until a full message arrives; a session has ONE reader — shutdown() is the cross-thread wake-up.
WebSocketSys.ClientGuardRoundTripWake a reader blocked in recv() WITHOUT freeing the session (see the free shutdown()).
0 on success, -1 on error.
O(1) + one syscall.
none.
safe to call from another thread while the owner's recv() blocks — that wake-up is its purpose; then join the reader before close().
WebSocketSys.ClientGuardRoundTripClose the connection now (idempotent — the destructor will not close it again).
0 on success, -1 if already closed.
one TLS write + teardown.
a small close frame (when still open).
WebSocketSys.ClientGuardRoundTrip