Poco::Net

class WebSocketImpl

File Information

Library: Net
Package: WebSocket
Header: Poco/Net/WebSocketImpl.h

Description

This class implements a WebSocket, according to the WebSocket protocol described in RFC 6455.

Inheritance

Direct Base Classes: StreamSocketImpl

All Base Classes: SocketImpl, StreamSocketImpl, Poco::RefCountedObject

Member Summary

Member Functions: acceptConnection, available, bind, bind6, close, connect, connectNB, frameFlags, getMaxPayloadSize, getReceiveTimeout, getSendTimeout, listen, mustMaskPayload, receiveBytes, receiveFrom, receiveHeader, receiveNBytes, receivePayload, receiveSomeBytes, secure, sendBytes, sendTo, sendUrgent, setMaxPayloadSize, setReceiveTimeout, setSendTimeout, shutdown, shutdownReceive, shutdownSend

Inherited Functions: acceptConnection, address, available, bind, bind6, checkBrokenTimeout, close, connect, connectNB, duplicate, error, fcntl, getBlocking, getBroadcast, getError, getKeepAlive, getLinger, getNoDelay, getOOBInline, getOption, getRawOption, getReceiveBufferSize, getReceiveTimeout, getReuseAddress, getReusePort, getSendBufferSize, getSendTimeout, init, initSocket, initialized, ioctl, lastError, listen, peerAddress, poll, receiveBytes, receiveFrom, referenceCount, release, reset, secure, sendBytes, sendFile, sendTo, sendUrgent, setBlocking, setBroadcast, setKeepAlive, setLinger, setNoDelay, setOOBInline, setOption, setRawOption, setReceiveBufferSize, setReceiveTimeout, setReuseAddress, setReusePort, setSendBufferSize, setSendTimeout, shutdown, shutdownReceive, shutdownSend, socketError, sockfd, type, useFileDescriptor

Enumerations

Anonymous protected

FRAME_FLAG_MASK = 0x80

MAX_HEADER_LENGTH = 14

Constructors

WebSocketImpl

WebSocketImpl(
    StreamSocketImpl * pStreamSocketImpl,
    HTTPSession & session,
    bool mustMaskPayload
);

Creates a WebSocketImpl.

Destructor

~WebSocketImpl protected virtual

virtual ~WebSocketImpl();

Member Functions

acceptConnection virtual

virtual SocketImpl * acceptConnection(
    SocketAddress & clientAddr
);

available virtual

virtual int available();

bind virtual

virtual void bind(
    const SocketAddress & address,
    bool reuseAddress = false
);

bind virtual

virtual void bind(
    const SocketAddress & address,
    bool reuseAddress,
    bool reusePort
);

bind6 virtual

virtual void bind6(
    const SocketAddress & address,
    bool reuseAddress = false,
    bool ipV6Only = false
);

bind6 virtual

virtual void bind6(
    const SocketAddress & address,
    bool reuseAddress,
    bool reusePort,
    bool ipV6Only
);

close virtual

virtual void close();

connect virtual

virtual void connect(
    const SocketAddress & address
);

connect virtual

virtual void connect(
    const SocketAddress & address,
    const Poco::Timespan & timeout
);

connectNB virtual

virtual void connectNB(
    const SocketAddress & address
);

frameFlags inline

int frameFlags() const;

Returns the frame flags of the most recently received frame.

getMaxPayloadSize inline

int getMaxPayloadSize() const;

Returns the maximum payload size for receiveFrame().

The default is std::numeric_limits<int>::max().

getReceiveTimeout virtual

virtual Poco::Timespan getReceiveTimeout();

getSendTimeout virtual

virtual Poco::Timespan getSendTimeout();

listen virtual

virtual void listen(
    int backlog = 64
);

mustMaskPayload inline

bool mustMaskPayload() const;

Returns true if the payload must be masked.

receiveBytes virtual

virtual int receiveBytes(
    void * buffer,
    int length,
    int flags
);

Receives a WebSocket protocol frame.

receiveBytes virtual

virtual int receiveBytes(
    Poco::Buffer < char > & buffer,
    int flags = 0,
    const Poco::Timespan & span = 0
);

Receives a WebSocket protocol frame.

receiveFrom virtual

virtual int receiveFrom(
    void * buffer,
    int length,
    SocketAddress & address,
    int flags = 0
);

secure virtual

virtual bool secure() const;

sendBytes virtual

virtual int sendBytes(
    const void * buffer,
    int length,
    int flags
);

Sends a WebSocket protocol frame.

sendTo virtual

virtual int sendTo(
    const void * buffer,
    int length,
    const SocketAddress & address,
    int flags = 0
);

sendUrgent virtual

virtual void sendUrgent(
    unsigned char data
);

setMaxPayloadSize

void setMaxPayloadSize(
    int maxPayloadSize
);

Sets the maximum payload size for receiveFrame().

The default is std::numeric_limits<int>::max().

setReceiveTimeout virtual

virtual void setReceiveTimeout(
    const Poco::Timespan & timeout
);

setSendTimeout virtual

virtual void setSendTimeout(
    const Poco::Timespan & timeout
);

shutdown virtual

virtual void shutdown();

shutdownReceive virtual

virtual void shutdownReceive();

shutdownSend virtual

virtual void shutdownSend();

receiveHeader protected

int receiveHeader(
    char mask[4],
    bool & useMask
);

receiveNBytes protected

int receiveNBytes(
    void * buffer,
    int bytes
);

receivePayload protected

int receivePayload(
    char * buffer,
    int payloadLength,
    char mask[4],
    bool useMask
);

receiveSomeBytes protected

int receiveSomeBytes(
    char * buffer,
    int bytes
);