IPWorks WebSockets 2020 C++ Edition

Questions / Feedback?

WebSocketServer Class

Properties   Methods   Events   Configuration Settings   Errors  

The WebSocketServer class is used to create a WebSocket server.

Syntax

WebSocketServer

Remarks

The WebSocketServer class provides an easy way to accept connections from WebSocket clients and transfer data.

The WebSocketServer class is a server that accepts incoming WebSocket connections and provides an easy way to send and receive data over the connection.

To begin using the class first specify a valid value for LocalPort. This is the port on which incoming connections will be accepted. To begin listening set Listening to True.

When a client connects the WebSocketOpenRequest event will fire. To accept the connection simply allow the event to complete. To reject the request set the StatusCode parameter to an HTTP error code (such as 401).

Once the connection is received incoming data will be provide through the DataIn event. To send data to a client you may use the Send, SendText, or SendFile methods. You may also set WebSocketConnectionDataToSend.

Note: Server components are designed to process events as they occur. To ensure events are processed in a timely manner DoEvents should be called in a loop after the server is started.

Property List


The following is the full list of the properties of the class with short descriptions. Click on the links for further details.

ConnectionBacklogThe maximum number of pending connections maintained by the TCP/IP subsystem.
WebSocketConnectionCountThe number of records in the WebSocketConnection arrays.
WebSocketConnectionAcceptDataSetting this property to False, temporarily disables data reception (and the DataIn event) on the connection.
WebSocketConnectionBytesSentThis property shows how many bytes were sent after the last assignment to DataToSend .
WebSocketConnectionConnectedThis property is used to disconnect individual connections and/or show their status.
WebSocketConnectionConnectionIdThis property contains an identifier generated by the class to identify each connection.
WebSocketConnectionDataFormatThe format of the data being sent.
WebSocketConnectionDataToSendThis property contains a string of data to be sent to the remote host.
WebSocketConnectionHostThe Host header value of the connected client.
WebSocketConnectionLocalAddressThis property shows the IP address of the interface through which the connection is passing.
WebSocketConnectionOriginThe Origin header value of the connected client.
WebSocketConnectionReadyToSendIndicates whether the class is ready to send data.
WebSocketConnectionRemoteHostThis property shows the IP address of the connected client.
WebSocketConnectionRemotePortThis property shows the port of the connected client.
WebSocketConnectionRequestHeadersThe HTTP headers sent by the client in the initial WebSocket connection request.
WebSocketConnectionRequestURIThe requested URI sent by the client in the initial WebSocket connection request.
WebSocketConnectionSubProtocolsThe subprotocols (application-level protocols layered over the WebSocket Protocol) sent by the client in the initial WebSocket connection request.
WebSocketConnectionTimeoutThis property specifies a timeout for the class.
DefaultTimeoutAn initial timeout value to be used by incoming connections.
ListeningIf True, the class accepts incoming connections on LocalPort.
LocalHostThe name of the local host or user-assigned IP interface through which connections are initiated or accepted.
LocalPortThe TCP port in the local host where the class listens.
SSLAuthenticateClientsIf true, the server asks the client(s) for a certificate.
SSLCertEncodedThe certificate (PEM/base64 encoded).
SSLCertStoreThe name of the certificate store for the client certificate.
SSLCertStorePasswordIf the certificate store is of a type that requires a password, this property is used to specify that password in order to open the certificate store.
SSLCertStoreTypeThe type of certificate store for this certificate.
SSLCertSubjectThe subject of the certificate used for client authentication.
UseSSLDetermines if SSL is negotiated with incoming connections.

Method List


The following is the full list of the methods of the class with short descriptions. Click on the links for further details.

ConfigSets or retrieves a configuration setting.
DisconnectDisconnect the specified client.
DoEventsProcesses events from the internal message queue.
InterruptInterrupts a synchronous send to the remote host.
SendSends binary data to the client.
SendFileSend file to the remote host.
SendTextSends text data to the client.
ShutdownShuts down the server.

Event List


The following is the full list of the events fired by the class with short descriptions. Click on the links for further details.

ConnectedFired when a WebSocket is successfully opened.
ConnectionRequestFired when a request for connection comes from a remote host.
DataInFired when data is received.
DisconnectedFired when a WebSocket connection is disconnected.
ErrorInformation about errors during data delivery.
LogFires once for each log message.
ReadyToSendFired when the class is ready to send data.
SSLClientAuthenticationFired when the client presents its credentials to the server.
SSLConnectionRequestFires when an SSL connection is requested.
SSLStatusShows the progress of the secure connection.
WebSocketOpenRequestFired when a client attempts to open a WebSocket.

Configuration Settings


The following is a list of configuration settings for the class with short descriptions. Click on the links for further details.

BufferMessageIndicates whether or not the entire message is buffered before firing the DataIn event.
DisconnectStatusCodeSpecifies the status code when closing a connection.
DisconnectStatusDescriptionSpecifies the message associated with the disconnect status code.
MaxFrameSizeSpecifies the maximum size of the outgoing message in bytes before fragmentation occurs.
MessageLength[ConnectionId]The length of the message (in bytes) when sending asynchronously.
WaitForCloseResponseDetermines whether or not the class will forcibly close a connection.
AllowedClientsA comma-separated list of host names or IP addresses that can access the class.
BindExclusivelyWhether or not the class considers a local port reserved for exclusive use.
ConnectionUIDThe unique connectionId for a connection.
DefaultConnectionTimeoutThe inactivity timeout applied to the SSL handshake.
InBufferSizeThe size in bytes of the incoming queue of the socket.
KeepAliveIntervalThe retry interval, in milliseconds, to be used when a TCP keep-alive packet is sent and no response is received.
KeepAliveRetryCountThe number of keep-alive packets to be sent before the remotehost is considered disconnected.
KeepAliveTimeThe inactivity time in milliseconds before a TCP keep-alive packet is sent.
MaxConnectionsThe maximum number of connections available.
OutBufferSizeThe size in bytes of the outgoing queue of the socket.
TcpNoDelayWhether or not to delay when sending packets.
UseIOCPWhether to use the completion port I/O model.
UseIPv6Whether to use IPv6.
UseWindowsMessagesWhether to use the WSAAsyncSelect I/O model.
LogSSLPacketsControls whether SSL packets are logged when using the internal security API.
OpenSSLCADirThe path to a directory containing CA certificates.
OpenSSLCAFileName of the file containing the list of CA's trusted by your application.
OpenSSLCipherListA string that controls the ciphers to be used by SSL.
OpenSSLPrngSeedDataThe data to seed the pseudo random number generator (PRNG).
ReuseSSLSessionDetermines if the SSL session is reused.
SSLCACertFilePathsThe paths to CA certificate files on Unix/Linux.
SSLCACertsA newline separated list of CA certificate to use during SSL client authentication.
SSLCipherStrengthThe minimum cipher strength used for bulk encryption.
SSLEnabledCipherSuitesThe cipher suite to be used in an SSL negotiation.
SSLEnabledProtocolsUsed to enable/disable the supported security protocols.
SSLEnableRenegotiationWhether the renegotiation_info SSL extension is supported.
SSLIncludeCertChainWhether the entire certificate chain is included in the SSLServerAuthentication event.
SSLNegotiatedCipherReturns the negotiated ciphersuite.
SSLNegotiatedCipherStrengthReturns the negotiated ciphersuite strength.
SSLNegotiatedCipherSuiteReturns the negotiated ciphersuite.
SSLNegotiatedKeyExchangeReturns the negotiated key exchange algorithm.
SSLNegotiatedKeyExchangeStrengthReturns the negotiated key exchange algorithm strength.
SSLNegotiatedProtocolReturns the negotiated protocol version.
SSLProviderThe name of the security provider to use.
SSLSecurityFlagsFlags that control certificate verification.
SSLServerCACertsA newline separated list of CA certificate to use during SSL server certificate validation.
TLS12SignatureAlgorithmsDefines the allowed TLS 1.2 signature algorithms when UseInternalSecurityAPI is True.
TLS12SupportedGroupsThe supported groups for ECC.
TLS13KeyShareGroupsThe groups for which to pregenerate key shares.
TLS13SignatureAlgorithmsThe allowed certificate signature algorithms.
TLS13SupportedGroupsThe supported groups for (EC)DHE key exchange.

Copyright (c) 2022 /n software inc. - All rights reserved.
IPWorks WebSockets 2020 C++ Edition - Version 20.0 [Build 8155]