Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include "TCPGenericSrvThread.h"
00016 #include "GenericAppMsg_m.h"
00017
00018
00019
00020 Register_Class(TCPGenericSrvThread);
00021
00022
00023 void TCPGenericSrvThread::established()
00024 {
00025
00026 }
00027
00028 void TCPGenericSrvThread::dataArrived(cMessage *msg, bool)
00029 {
00030 GenericAppMsg *appmsg = dynamic_cast<GenericAppMsg *>(msg);
00031 if (!appmsg)
00032 opp_error("Message (%s)%s is not a GenericAppMsg -- "
00033 "probably wrong client app, or wrong setting of TCP's "
00034 "sendQueueClass/receiveQueueClass parameters "
00035 "(try \"TCPMsgBasedSendQueue\" and \"TCPMsgBasedRcvQueue\")",
00036 msg->getClassName(), msg->getName());
00037 if (appmsg->getReplyDelay()>0)
00038 opp_error("Cannot process (%s)%s: %s class doesn't support replyDelay field"
00039 " of GenericAppMsg, try to use TCPGenericSrvApp instead",
00040 msg->getClassName(), msg->getName(), getClassName());
00041
00042
00043
00044 long requestedBytes = appmsg->getExpectedReplyLength();
00045 bool doClose = appmsg->getServerClose();
00046
00047 if (requestedBytes==0)
00048 {
00049 delete appmsg;
00050 }
00051 else
00052 {
00053 appmsg->setByteLength(requestedBytes);
00054 delete appmsg->removeControlInfo();
00055 getSocket()->send(appmsg);
00056 }
00057
00058 if (doClose)
00059 {
00060 getSocket()->close();
00061 }
00062 }
00063
00064 void TCPGenericSrvThread::timerExpired(cMessage *timer)
00065 {
00066
00067 }
00068
00069