Public Member Functions

TCPGenericSrvThread Class Reference

#include <TCPGenericSrvThread.h>

Inheritance diagram for TCPGenericSrvThread:
TCPServerThreadBase TCPSocket::CallbackInterface

List of all members.

Public Member Functions

 TCPGenericSrvThread ()
virtual void established ()
virtual void dataArrived (cMessage *msg, bool urgent)
virtual void timerExpired (cMessage *timer)

Detailed Description

Example server thread, to be used with TCPSrvHostApp.

Definition at line 24 of file TCPGenericSrvThread.h.


Constructor & Destructor Documentation

TCPGenericSrvThread::TCPGenericSrvThread (  )  [inline]

Definition at line 27 of file TCPGenericSrvThread.h.

{}


Member Function Documentation

void TCPGenericSrvThread::dataArrived ( cMessage *  msg,
bool  urgent 
) [virtual]

Called when a data packet arrives. To be redefined.

Implements TCPServerThreadBase.

Definition at line 28 of file TCPGenericSrvThread.cc.

{
    GenericAppMsg *appmsg = dynamic_cast<GenericAppMsg *>(msg);
    if (!appmsg)
        opp_error("Message (%s)%s is not a GenericAppMsg -- "
                  "probably wrong client app, or wrong setting of TCP's "
                  "sendQueueClass/receiveQueueClass parameters "
                  "(try \"TCPMsgBasedSendQueue\" and \"TCPMsgBasedRcvQueue\")",
                  msg->getClassName(), msg->getName());
    if (appmsg->getReplyDelay()>0)
        opp_error("Cannot process (%s)%s: %s class doesn't support replyDelay field"
                  " of GenericAppMsg, try to use TCPGenericSrvApp instead",
                  msg->getClassName(), msg->getName(), getClassName());

    // process message: send back requested number of bytes, then close
    // connection if that was requested too
    long requestedBytes = appmsg->getExpectedReplyLength();
    bool doClose = appmsg->getServerClose();

    if (requestedBytes==0)
    {
        delete appmsg;
    }
    else
    {
        appmsg->setByteLength(requestedBytes);
        delete appmsg->removeControlInfo();
        getSocket()->send(appmsg);
    }

    if (doClose)
    {
        getSocket()->close();
    }
}

void TCPGenericSrvThread::established (  )  [virtual]

Called when connection is established. To be redefined.

Implements TCPServerThreadBase.

Definition at line 23 of file TCPGenericSrvThread.cc.

{
    // no initialization needed
}

void TCPGenericSrvThread::timerExpired ( cMessage *  timer  )  [virtual]

Called when a timer (scheduled via scheduleAt()) expires. To be redefined.

Implements TCPServerThreadBase.

Definition at line 64 of file TCPGenericSrvThread.cc.

{
    // no timers in this serverThread
}


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