IPDaemon Class

Properties   Methods   Events   Configuration Settings   Errors  

The IPDaemon Class is a generic TCP server class based on an asynchronous, event-driven architecture. It is designed to balance the load between connections for a fast, powerful server.

Class Name

IPWorks_IPDaemon

Procedural Interface

 ipworks_ipdaemon_open();
 ipworks_ipdaemon_close($res);
 ipworks_ipdaemon_register_callback($res, $id, $function);
 ipworks_ipdaemon_get_last_error($res);
 ipworks_ipdaemon_get_last_error_code($res);
 ipworks_ipdaemon_set($res, $id, $index, $value);
 ipworks_ipdaemon_get($res, $id, $index);
 ipworks_ipdaemon_do_config($res, $configurationstring);
 ipworks_ipdaemon_do_disconnect($res, $connectionid);
 ipworks_ipdaemon_do_doevents($res);
 ipworks_ipdaemon_do_interrupt($res, $connectionid);
 ipworks_ipdaemon_do_reset($res);
 ipworks_ipdaemon_do_send($res, $connectionid, $text);
 ipworks_ipdaemon_do_sendfile($res, $connectionid, $filename);
 ipworks_ipdaemon_do_sendline($res, $connectionid, $text);
 ipworks_ipdaemon_do_shutdown($res);
 ipworks_ipdaemon_do_startssl($res, $connectionid);

Remarks

The IPDaemon Class supports both plaintext and SSL/TLS connections. When connecting over SSL/TLS the SSLServerAuthentication event allows you to check the server identity and other security attributes. The SSLStatus event provides information about the SSL handshake. Additional SSL related settings are also supported via the Config method. The SSLCert properties are used to select a certificate for the server (please note that a valid certificate MUST be selected before the server can function).

IPDaemon is the server complement of IPPort (which is used to create client applications). They share a common design philosophy and interface. We expect you will find IPDaemon as easy to use as IPPort.

By default, each instance of IPDaemon can handle up to 1,000 simultaneous incoming connections (this number may be increased up to 100,000 or decreased to a lower value by using the MaxConnections configuration setting).

The connections are identified by a ConnectionId, an id generated by the component to identify each connection. This id is unique to each connection. IPDaemon's events also have ConnectionId as a parameter to identify the connection they relate to.

Our main goal in designing IPDaemon was to make it easy to use without sacrificing performance. The class has a minimum of properties, and six events: ConnectionRequest, Connected, DataIn, Disconnected, ReadyToSend, and Error.

IPDaemon can start to listen on a port by setting the Listening property to True. When a remote host asks for a connection, the ConnectionRequest event is fired. At that point, the connection can either be accepted or rejected. If the connection is accepted, a ConnectionId is assigned, and communication can start. From this point on, the operation is very similar to IPPort. Data is sent by assigning the data string to the DataToSend property. The address and port of the incoming connection can be found by querying the RemoteHost and RemotePort properties.

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.
ConnectionCountThe number of records in the arrays.
AcceptDataSetting this property to False, temporarily disables data reception (and the DataIn event) on the connection.
BytesSentThis property shows how many bytes were sent after the last assignment to DataToSend .
ConnectedThis property is used to disconnect individual connections and/or show their status.
ConnectionIdThis property contains an identifier generated by the class to identify each connection.
DataToSendThis property contains a string of data to be sent to the remote host.
EOLThe EOL property is used to define boundaries in the input stream using the value of the property.
IdleTimeoutThe idle timeout for this connection.
LocalAddressThis property shows the IP address of the interface through which the connection is passing.
ReadyToSendIndicates whether the class is ready to send data.
RecordLengthIf set to a positive value, this setting defines the length of data records to be received.
RemoteHostThis property shows the IP address of the remote host through which the connection is coming.
RemotePortThis property shows the TCP port on the remote host through which the connection is coming.
SingleLineModeThis property shows the special mode for line-oriented protocols.
TimeoutThis property specifies a timeout for the class.
UserDataThe UserData property holds connection specific user specified data.
DefaultEOLA default EOL value to be used by incoming connections.
DefaultIdleTimeoutThe default idle timeout for inactive clients.
DefaultMaxLineLengthThe default maximum line length value for inbound connections.
DefaultSingleLineModeTells the class whether or not to treat new connections as line-oriented.
DefaultTimeoutAn initial timeout value to be used by incoming connections.
KeepAliveWhen True, KEEPALIVE packets are enabled (for long connections).
LingerWhen set to True, connections are terminated gracefully.
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.
SSLEnabledWhether TLS/SSL is enabled.
SSLStartModeDetermines how the class starts the SSL negotiation.

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.
ResetReset the class.
SendSends data to the remote host.
SendFileSend file to the remote host.
SendLineSends a string followed by a newline.
ShutdownShuts down the server.
StartSSLStarts SSL negotiation on a connection.

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 immediately after a connection completes (or fails).
ConnectionRequestFired when a request for connection comes from a remote host.
DataInFired when data comes in.
DisconnectedFired when a connection is closed.
ErrorInformation about errors during data delivery.
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.

Configuration Settings


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

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.
SSLCheckCRLWhether to check the Certificate Revocation List for the server certificate.
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.
SSLNegotiatedVersionReturns 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.
BuildInfoInformation about the product's build.
CodePageThe system code page used for Unicode to Multibyte translations.
LicenseInfoInformation about the current license.
ProcessIdleEventsWhether the class uses its internal event loop to process events when the main thread is idle.
SelectWaitMillisThe length of time in milliseconds the class will wait when DoEvents is called if there are no events to process.
UseInternalSecurityAPITells the class whether or not to use the system security libraries or an internal implementation.

Copyright (c) 2022 /n software inc. - All rights reserved.
IPWorks 2020 PHP Edition - Version 20.0 [Build 8307]