INET Framework for OMNeT++/OMNEST
inet::TCPGenericSrvThread Class Reference

Example server thread, to be used with TCPSrvHostApp. More...

#include <TCPGenericSrvThread.h>

Inheritance diagram for inet::TCPGenericSrvThread:
inet::TCPServerThreadBase inet::TCPSocket::CallbackInterface

Public Member Functions

 TCPGenericSrvThread ()
 
virtual void established () override
 Called when connection is established. More...
 
virtual void dataArrived (cMessage *msg, bool urgent) override
 
virtual void timerExpired (cMessage *timer) override
 
- Public Member Functions inherited from inet::TCPServerThreadBase
 TCPServerThreadBase ()
 
virtual ~TCPServerThreadBase ()
 
virtual void init (TCPSrvHostApp *hostmodule, TCPSocket *socket)
 
virtual TCPSocketgetSocket ()
 
virtual TCPSrvHostAppgetHostModule ()
 
virtual void scheduleAt (simtime_t t, cMessage *msg)
 Schedule an event. More...
 
virtual void cancelEvent (cMessage *msg)
 
virtual void peerClosed ()
 
virtual void closed ()
 
virtual void failure (int code)
 
virtual void statusArrived (TCPStatusInfo *status)
 
- Public Member Functions inherited from inet::TCPSocket::CallbackInterface
virtual ~CallbackInterface ()
 
virtual void socketDeleted (int connId, void *yourPtr)
 

Additional Inherited Members

- Protected Member Functions inherited from inet::TCPServerThreadBase
virtual void socketDataArrived (int, void *, cPacket *msg, bool urgent) override
 
virtual void socketEstablished (int, void *) override
 
virtual void socketPeerClosed (int, void *) override
 
virtual void socketClosed (int, void *) override
 
virtual void socketFailure (int, void *, int code) override
 
virtual void socketStatusArrived (int, void *, TCPStatusInfo *status) override
 
- Protected Attributes inherited from inet::TCPServerThreadBase
TCPSrvHostApphostmod
 
TCPSocketsock
 

Detailed Description

Example server thread, to be used with TCPSrvHostApp.

Constructor & Destructor Documentation

inet::TCPGenericSrvThread::TCPGenericSrvThread ( )
inline
33 {}

Member Function Documentation

void inet::TCPGenericSrvThread::dataArrived ( cMessage *  msg,
bool  urgent 
)
overridevirtual

Implements inet::TCPServerThreadBase.

32 {
33  GenericAppMsg *appmsg = dynamic_cast<GenericAppMsg *>(msg);
34 
35  if (!appmsg)
36  throw cRuntimeError("Message (%s)%s is not a GenericAppMsg -- "
37  "probably wrong client app, or wrong setting of TCP's "
38  "dataTransferMode parameters "
39  "(try \"object\")",
40  msg->getClassName(), msg->getName());
41 
42  if (appmsg->getReplyDelay() > 0)
43  throw cRuntimeError("Cannot process (%s)%s: %s class doesn't support replyDelay field"
44  " of GenericAppMsg, try to use TCPGenericSrvApp instead",
45  msg->getClassName(), msg->getName(), getClassName());
46 
47  // process message: send back requested number of bytes, then close
48  // connection if that was requested too
49  long requestedBytes = appmsg->getExpectedReplyLength();
50  bool doClose = appmsg->getServerClose();
51 
52  if (requestedBytes == 0) {
53  delete appmsg;
54  }
55  else {
56  appmsg->setByteLength(requestedBytes);
57  delete appmsg->removeControlInfo();
58  getSocket()->send(appmsg);
59  }
60 
61  if (doClose)
62  getSocket()->close();
63 }
virtual TCPSocket * getSocket()
Definition: TCPSrvHostApp.h:87
void send(cMessage *msg)
Sends data packet.
Definition: TCPSocket.cc:175
void close()
Closes the local end of the connection.
Definition: TCPSocket.cc:192
void inet::TCPGenericSrvThread::established ( )
overridevirtual

Called when connection is established.

To be redefined.

Implements inet::TCPServerThreadBase.

27 {
28  // no initialization needed
29 }
void inet::TCPGenericSrvThread::timerExpired ( cMessage *  timer)
overridevirtual

Implements inet::TCPServerThreadBase.

66 {
67  // no timers in this serverThread
68 }

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