Status & Roadmap
Authors & License
Funding Ultimate++
Search on this site

SourceForge.net Logo



class WebSocket

Provides the WebSocket protocol support.



Public Method List


WebSocket& NonBlocking(bool b = true)

If b is true, activates non-blocking mode. Default is blocking mode.



bool IsBlocking() const

Returns true if WebSocket is in the blocking mode.



bool IsError() const

Returns true if there was any error.



String GetError() const

Returns the description of error.



bool Accept(TcpSocket& listen_socket)

Accepts connection from listen_socket. Returns true on success.



bool Connect(const String& url)

Initiates connection to url. In blocking mode returns false if connection cannot be established, otherwise true.



void Do()

Manages socket operations in non-blocking mode. Cannot be called in blocking mode.



String Receive()

Receives the message. In blocking mode waits until the message is available. In non-blocking mode returns either message or String::GetVoid() if there is no message. In both cases also returns String::GetVoid() in case of exceptional situations (errors, connection closed etc...). Note that in non-blocking mode Receive calls Do, so there is no need to call it separately.



bool IsFin() const

Returns true if the last received message had flag FIN set.



bool IsText() const

Returns true if the last received message was text.



bool IsBinary() const

Returns true if the last received message was text.



void SendText(const String& data)

Sends a single frame (non-fragmented) text message.



void SendBinary(const String& data)

Sends a single frame (non-fragmented) binary message.



void BeginText(const String& data)

Starts a multi-frame (fragmented) text message.



void BeginBinary(const String& data)

Starts a multi-frame (fragmented) binary message.



void Continue(const String& data)

Sends another chunk of data in a multi-frame (fragmented) message.



void Fin(const String& data)

Sends the final chunk of data in a multi-frame (fragmented) message.



void Close(const String& msg)

Initiates standard close of connection, sending CLOSE msg.



bool IsOpen()

Returns true if the socket is open.



bool IsClosed() const

Returns true if the socket is closed.


dword GetWaitEvents() const

Returns a combination of WAIT_READ and WAIT_WRITE flags to indicate what is blocking the operation of WebSocket. Can be used with SocketWaitEvent.




Is there associated socket, returns its handle. Otherwise returns NULL.



void AddTo(SocketWaitEvent& e)

Adds WebSocket to SocketWaitEvent for waiting on it.



void Trace(bool b)

Activates tracing log.



Last edit by cxl on 11/15/2017. Do you want to contribute?. T++