Simple Module TCPSrvHostApp

File: Applications/TCPApp/TCPSrvHostApp.ned

C++ definition: click here

This module 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 Register_Class() macro, and the class name should be specified in the serverThreadClass parameter of TCPSrvHostApp. 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.

Example server thread class: TCPGenericSrvThread (in the C++ documentation only).

IMPORTANT: Before you try to use this module, make sure you actually need it! In most cases, TCPGenericSrvApp and GenericAppMsg will be completely enough, and they are a lot easier to handle. You'll want to subclass your client from TCPGenericCliAppBase then; check TelnetApp and TCPBasicClientApp for examples.

Compatible with both IPv4 and IPv6.

Usage diagram:

The following diagram shows usage relationships between modules, networks and channels. Unresolved module (and channel) types are missing from the diagram. Click here to see the full picture.

Parameters:

Name Type Description
address string

may be left empty ("")

port numeric const

port number to listen on

serverThreadClass string

class name of "thread" objects to launch on incoming connections

Gates:

Name Direction Description
tcpIn input
tcpOut output

Source code:

simple TCPSrvHostApp
    parameters:
        address: string, // may be left empty ("")
        port: numeric const, // port number to listen on
        serverThreadClass : string; // class name of "thread" objects to launch on incoming connections
    gates:
        in: tcpIn;
        out: tcpOut;
endsimple