TcpServerHostApp¶
Package: inet.applications.tcpapp
simple module TcpServerHostApp
Hosts TCP-based server applications. It dynamically creates and launches a new “thread” object for each incoming connection.
Server threads should be subclassed from the TcpServerThreadBase
C++ class, registered in the C++ code using the Define_Module() macro,
and the module type should be specified in the serverThreadModuleType
parameter of TcpServerHostApp. The thread object will receive events
via a callback interface (methods like established(), dataArrived(),
peerClosed(), timerExpired()), and can send packets via TcpSocket’s send()
method.
Compatible with both Ipv4 and Ipv6.
Inheritance diagram¶
Known subclasses¶
Name |
Type |
Description |
|---|---|---|
simple module |
Accepts any number of incoming TCP connections, and sends back the data that arrives on them. The |
|
compound module |
Accepts any number of incoming TCP connections, and discards whatever arrives on them. Compatible with both Ipv4 and Ipv6. |
Extends¶
Name |
Type |
Description |
|---|---|---|
simple module |
Base module for all INET simple modules. |
Parameters¶
Name |
Type |
Default value |
Description |
|---|---|---|---|
displayStringTextFormat |
string |
“{numThreads} threads” |
Determines the text that is written on top of the submodule, supports displaying pars, watches, and module-specific information |
localAddress |
string |
“” |
May be left empty (“”) |
localPort |
int |
1000 |
Port number to listen on |
serverThreadModuleType |
string |
Module type of “thread” module to launch on incoming connections |
|
stopOperationExtraTime |
double |
-1s |
Extra time after lifecycle stop operation finished |
stopOperationTimeout |
double |
2s |
Timeout value for lifecycle stop operation |
Properties¶
Name |
Value |
Description |
|---|---|---|
class |
TcpServerHostApp |
|
display |
i=block/app |
|
lifecycleSupport |
Gates¶
Name |
Direction |
Size |
Description |
|---|---|---|---|
socketIn |
input |
||
socketOut |
output |
Source code¶
//
// Hosts TCP-based server applications. It dynamically creates
// and launches a new "thread" object for each incoming connection.
//
// Server threads should be subclassed from the `TcpServerThreadBase`
// C++ class, registered in the C++ code using the Define_Module() macro,
// and the module type should be specified in the `serverThreadModuleType`
// parameter of ~TcpServerHostApp. The thread object will receive events
// via a callback interface (methods like established(), `dataArrived()`,
// `peerClosed()`, `timerExpired()`), and can send packets via `TcpSocket`'s send()
// method.
//
// Compatible with both ~Ipv4 and ~Ipv6.
//
simple TcpServerHostApp extends SimpleModule like IApp
{
parameters:
@class(TcpServerHostApp);
string localAddress = default(""); // May be left empty ("")
int localPort = default(1000); // Port number to listen on
string serverThreadModuleType; // Module type of "thread" module to launch on incoming connections
displayStringTextFormat = default("{numThreads} threads");
@display("i=block/app");
@lifecycleSupport;
double stopOperationExtraTime @unit(s) = default(-1s); // Extra time after lifecycle stop operation finished
double stopOperationTimeout @unit(s) = default(2s); // Timeout value for lifecycle stop operation
gates:
input socketIn @labels(TcpCommand/up);
output socketOut @labels(TcpCommand/down);
}