Package: inet.applications.tcpapp
TcpServerHostApp
simple moduleHosts 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
The following diagram shows inheritance relationships for this type. Unresolved types are missing from the diagram.
Known subclasses
| Name | Type | Description |
|---|---|---|
| TcpEchoApp | simple module |
Accepts any number of incoming TCP connections, and sends back the data that arrives on them. The echoFactor parameter controls the amount of data to be sent back. If echoFactor==1, the received data is echoed back without change. For any other positive value of echoFactor, a message of appropriate length (datalen*echoFactor) without content (see ByteCountChunk C++ class) is sent back. |
| TcpSinkApp | 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 |
|---|---|---|
| SimpleModule | simple module |
Base module for all INET simple modules. |
Parameters
| Name | Type | Default value | Description |
|---|---|---|---|
| displayStringTextFormat | string | "" |
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 @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); }File: src/inet/applications/tcpapp/TcpServerHostApp.ned