|
INET Framework for OMNeT++/OMNEST
|
#include <TCPGenericSrvThread.h>
Public Member Functions | |
| TCPGenericSrvThread () | |
| virtual void | established () |
| virtual void | dataArrived (cMessage *msg, bool urgent) |
| virtual void | timerExpired (cMessage *timer) |
Example server thread, to be used with TCPSrvHostApp.
| TCPGenericSrvThread::TCPGenericSrvThread | ( | ) | [inline] |
{}
| void TCPGenericSrvThread::dataArrived | ( | cMessage * | msg, |
| bool | urgent | ||
| ) | [virtual] |
Called when a data packet arrives. To be redefined.
Implements TCPServerThreadBase.
{
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.
{
// no initialization needed
}
| void TCPGenericSrvThread::timerExpired | ( | cMessage * | timer | ) | [virtual] |
Called when a timer (scheduled via scheduleAt()) expires. To be redefined.
Implements TCPServerThreadBase.
{
// no timers in this serverThread
}