Rudiments
Public Member Functions | List of all members
websocket Class Reference

#include <websocket.h>

Inherits socketlayer.

Public Member Functions

 websocket ()
 
virtual ~websocket ()
 
void setFileDescriptor (filedescriptor *fd)
 
filedescriptorgetFileDescriptor ()
 
bool connect ()
 
bool accept ()
 
ssize_t read (void *buf, size_t size)
 
ssize_t write (const void *buf, size_t size)
 
bool ping (const byte_t *buf, size_t size)
 
size_t getPendingSize ()
 
bool close ()
 
size_t getSizeMax ()
 
- Public Member Functions inherited from object
virtual ~object ()
 

Detailed Description

The websocket class implements the socketlayer interface for Web Sockets.

Constructor & Destructor Documentation

◆ websocket()

websocket::websocket ( )

Creates a new instance of the websocket class.

◆ ~websocket()

virtual websocket::~websocket ( )
virtual

Deletes this instance of the websocket class.

Member Function Documentation

◆ accept()

bool websocket::accept ( )

Accepts a security context from the client with whom a connection is already established across the filedescriptor previously set using setFileDescriptor().

Note that if this instance is set as the current GSS context of a child of the socketserver class, then this method is called implicitly during a successful call to accept().

Returns true on success and false on failure.

◆ close()

bool websocket::close ( )

Releases any security context established during the previous call to connect() or accept().

◆ connect()

bool websocket::connect ( )

Initiates a security context with the server with whom a connection is already established across the filedescriptor previously set using setFileDescriptor().

Note that if this instance is set as the current security context of a child of the socketclient class, then this method is called implicitly during a successful call to connect().

Returns true on success and false on failure.

◆ getFileDescriptor()

filedescriptor * websocket::getFileDescriptor ( )
virtual

Returns the file descrptor that will be used to communicate with the peer during the next call to connect() or accept().

Implements socketlayer.

◆ getPendingSize()

size_t websocket::getPendingSize ( )

Returns the number of bytes that are buffered and available for immediate read.

◆ getSizeMax()

size_t websocket::getSizeMax ( )

Returns the maximum number of bytes that can be written or read in a single call to write() or read().

◆ ping()

bool websocket::ping ( const byte_t * buf,
size_t size )

Pings the peer with "size" bytes of "buf" data. Returns true if the peer responds with the same data or false if the peer doesn't respond or responds with different data.

◆ read()

ssize_t websocket::read ( void * buf,
size_t size )

Reads from the file descriptor previously configured by setFileDescriptor() into "buf" until "size" bytes have been read. Returns the number of bytes that were written to "buf" or RESULT_ERROR if an error occurred.

◆ setFileDescriptor()

void websocket::setFileDescriptor ( filedescriptor * fd)
virtual

Sets the file descriptor that will be used to communicate with the peer during the next call to connect() or accept().

Implements socketlayer.

◆ write()

ssize_t websocket::write ( const void * buf,
size_t size )

Writes "size" bytes from "buf" to the file descriptor previously configured by setFileDescriptor(). Returns the number of bytes that were written or RESULT_ERROR if an error occurred.