IP*Works! 2016 .NET Edition
IP*Works! 2016 .NET Edition
Questions / Feedback?

IPDaemon Component

Properties   Methods   Events   Configuration Settings   Errors  

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

Syntax

nsoftware.IPWorks.Ipdaemon

Remarks

The IPDaemon Component 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 handhsake. 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 component 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.

Threading in Server Applications

In .NET, all socket-based components perform all socket IO through asynchronous methods. Each call consumes a thread from the system's thread pool, and thus the number of concurrent calls is limited to the number of worker threads returned by System.Threading.ThreadPool.GetMaxThreads. When using several components that can each create a socket connection or a single component that can create multiple socket connections, the application may enter a state where all of the pool threads are in use for receiving. In a scenario such as this, the remote hosts may be waiting for data from the application before sending, but the application cannot send that data because all the threads are tied up waiting for inbound data. This is particularly important for server applications that use a daemon component.

For example, say a server application 'S' has a max thread pool size of three, and clients 'A' and 'B' connect to it and each client uploads a large file. After all uploads are complete, 'S' enqueues an asynchronous read request in the thread pool for each client. Since there is no work being done, the thread pool immediately consumes two threads which wait for any further data from 'A' and 'B'. While 'S' is still processing the first two files it has received, client 'C' connects and uploads a relatively small file. Similarly, once that upload has completed 'S' enqueues a third read request, and the thread pool immediately consumes the third and final thread to wait for further data from 'C'. Once 'S' completes processing any of the files it will enqueue a send request. However, since all three threads are in use and waiting for data from the clients, the send operation cannot be completed. The entire system becomes deadlocked because each of the clients is waiting for data from the server, which cannot send that data since all of its pool threads are in turn waiting for data from the clients.

To avoid a deadlock situation such as this, it is necessary to ensure that the maximum number of socket connections an application can make is always at least one less than the number of available worker threads. One method to achieve this is to call System.Threading.ThreadPool.SetMaxThreads during the application's startup to set the maximum number of threads to a value high enough to support the application for the duration of its execution. Another option is to trap an event such as ConnectionRequest and Disconnected from each component instance with logic to manage the max thread pool size according to the application's current needs.

Property List


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

ConnectionBacklogThe maximum number of pending connections maintained by the TCP/IP subsystem.
ConnectionsA collection of currently connected clients.
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 component 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 component 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 component listens.
SSLAuthenticateClientsIf true, the server asks the client(s) for a certificate.
SSLCertThe certificate to be used during SSL negotiation.
SSLEnabledWhether TLS/SSL is enabled.
SSLStartModeDetermines how the component starts the SSL negotiation.

Method List


The following is the full list of the methods of the component 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 component.
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 component 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 component is ready to send data.
SSLClientAuthenticationFired when the client presents its credentials to the server.
SSLStatusShows the progress of the secure connection.

Configuration Settings


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

AllowedClientsA comma-separated list of host names or IP addresses that can access the component.
BindExclusivelyWhether or not the component considers a local port reserved for exclusive use.
DefaultConnectionTimeoutThe inactivity timeout applied to the SSL handshake.
InBufferSizeThe size in bytes of the incoming queue of the socket.
MaxConnectionsThe maximum number of connections available.
OutBufferSizeThe size in bytes of the outgoing queue of the socket.
KeepAliveTimeThe inactivity time in milliseconds before a TCP keep-alive packet is sent.
KeepAliveIntervalThe retry interval, in milliseconds, to be used when a TCP keep-alive packet is sent and no response is received.
UseIPv6Whether to use IPv6.
TcpNoDelayWhether or not to delay when sending packets.
CloseStreamAfterTransferIf true, the component will close the upload or download stream after the transfer.
CACertFilePathsThe paths to CA certificate files when using Mono on Unix/Linux.
LogSSLPacketsControls whether SSL packets are logged when using the internal security API.
ReuseSSLSessionDetermines if the SSL session is reused.
SSLCipherStrengthThe minimum cipher strength used for bulk encryption.
SSLEnabledProtocolsUsed to enable/disable the supported security protocols.
SSLIncludeCertChainWhether the entire certificate chain is included in the SSLServerAuthentication event.
SSLProviderThe name of the security provider to use.
SSLSecurityFlagsFlags that control certificate verification.
SSLCACertsA newline separated list of CA certificate to use during SSL client authentication.
SSLEnabledCipherSuitesThe cipher suite to be used in an SSL negotiation.
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.
TLS13SupportedGroupsThe supported groups for (EC)DHE key exchange.
TLS13SignatureAlgorithmsThe allowed certificate signature algorithms.
GUIAvailableTells the component whether or not a message loop is available for processing events.
UseBackgroundThreadWhether threads created by the component are background threads.
UseInternalSecurityAPITells the component whether or not to use the system security libraries or an internal implementation.

 
 
Copyright (c) 2020 /n software inc. - All rights reserved.
IP*Works! 2016 .NET Edition - Version 16.0 [Build 7353]