Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

TCPSrvHostApp Class Reference

#include <TCPSrvHostApp.h>

List of all members.


Detailed Description

Hosts a server application, to be subclassed from TCPServerProcess (which is a sSimpleModule). Creates one instance (using dynamic module creation) for each incoming connection. More info in the corresponding NED file.


Public Member Functions

void removeThread (TCPServerThreadBase *thread)

Protected Member Functions

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

Protected Attributes

TCPSocket serverSocket
TCPSocketMap socketMap


Member Function Documentation

void TCPSrvHostApp::finish  )  [protected, virtual]
 

00071 {
00072 }

void TCPSrvHostApp::handleMessage cMessage *  msg  )  [protected, virtual]
 

00041 {
00042     if (msg->isSelfMessage())
00043     {
00044         TCPServerThreadBase *thread = (TCPServerThreadBase *)msg->contextPointer();
00045         thread->timerExpired(msg);
00046     }
00047     else
00048     {
00049         TCPSocket *socket = socketMap.findSocketFor(msg);
00050         if (!socket)
00051         {
00052             // new connection -- create new socket object and server process
00053             socket = new TCPSocket(msg);
00054             socket->setOutputGate(gate("tcpOut"));
00055 
00056             const char *serverThreadClass = par("serverThreadClass");
00057             TCPServerThreadBase *proc = check_and_cast<TCPServerThreadBase *>(createOne(serverThreadClass));
00058 
00059             socket->setCallbackObject(proc);
00060             proc->init(this, socket);
00061 
00062             socketMap.addSocket(socket);
00063 
00064             updateDisplay();
00065         }
00066         socket->processMessage(msg);
00067     }
00068 }

void TCPSrvHostApp::initialize  )  [protected, virtual]
 

00022 {
00023     const char *address = par("address");
00024     int port = par("port");
00025 
00026     serverSocket.setOutputGate(gate("tcpOut"));
00027     serverSocket.bind(address[0] ? IPvXAddress(address) : IPvXAddress(), port);
00028     serverSocket.listen();
00029 }

void TCPSrvHostApp::removeThread TCPServerThreadBase thread  ) 
 

00075 {
00076     // remove socket
00077     socketMap.removeSocket(thread->socket());
00078 
00079     // remove thread object
00080     delete thread;
00081 
00082     updateDisplay();
00083 }

void TCPSrvHostApp::updateDisplay  )  [protected]
 

00032 {
00033     if (!ev.isGUI()) return;
00034 
00035     char buf[32];
00036     sprintf(buf, "%d threads", socketMap.size());
00037     displayString().setTagArg("t", 0, buf);
00038 }


Member Data Documentation

TCPSocket TCPSrvHostApp::serverSocket [protected]
 

TCPSocketMap TCPSrvHostApp::socketMap [protected]
 


The documentation for this class was generated from the following files:
Generated on Sat Apr 1 20:52:25 2006 for INET Framework for OMNeT++/OMNEST by  doxygen 1.4.1