INET Framework for OMNeT++/OMNEST
TCPSinkApp Class Reference

#include <TCPSinkApp.h>

List of all members.

Protected Member Functions

virtual void initialize ()
virtual void handleMessage (cMessage *msg)
virtual void finish ()

Protected Attributes

long bytesRcvd

Detailed Description

Accepts any number of incoming connections, and discards whatever arrives on them.


Member Function Documentation

void TCPSinkApp::finish ( ) [protected, virtual]
{
    recordScalar("bytesRcvd", bytesRcvd);
}
void TCPSinkApp::handleMessage ( cMessage *  msg) [protected, virtual]
{
    if (msg->getKind()==TCP_I_PEER_CLOSED)
    {
        // we close too
        msg->setKind(TCP_C_CLOSE);
        send(msg, "tcpOut");
    }
    else if (msg->getKind()==TCP_I_DATA || msg->getKind()==TCP_I_URGENT_DATA)
    {
        bytesRcvd += PK(msg)->getByteLength();
        delete msg;

        if (ev.isGUI())
        {
            char buf[32];
            sprintf(buf, "rcvd: %ld bytes", bytesRcvd);
            getDisplayString().setTagArg("t",0,buf);
        }
    }
    else
    {
        // must be data or some kind of indication -- can be dropped
        delete msg;
    }
}
void TCPSinkApp::initialize ( ) [protected, virtual]
{
    const char *address = par("address");
    int port = par("port");

    bytesRcvd = 0;
    WATCH(bytesRcvd);

    TCPSocket socket;
    socket.setOutputGate(gate("tcpOut"));
    socket.bind(address[0] ? IPvXAddress(address) : IPvXAddress(), port);
    socket.listen();
}

Member Data Documentation

long TCPSinkApp::bytesRcvd [protected]

Referenced by finish(), handleMessage(), and initialize().


The documentation for this class was generated from the following files: