TCPGenericCliAppBase.h

Go to the documentation of this file.
00001 //
00002 // Copyright 2004 Andras Varga
00003 //
00004 // This library is free software, you can redistribute it and/or modify
00005 // it under  the terms of the GNU Lesser General Public License
00006 // as published by the Free Software Foundation;
00007 // either version 2 of the License, or any later version.
00008 // The library is distributed in the hope that it will be useful,
00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00011 // See the GNU Lesser General Public License for more details.
00012 //
00013 
00014 #ifndef __INET_TCPGENERICCLIAPPBASE_H
00015 #define __INET_TCPGENERICCLIAPPBASE_H
00016 
00017 #include <omnetpp.h>
00018 #include "TCPSocket.h"
00019 
00020 
00029 class INET_API TCPGenericCliAppBase : public cSimpleModule, public TCPSocket::CallbackInterface
00030 {
00031   protected:
00032     TCPSocket socket;
00033 
00034     // statistics
00035     int numSessions;
00036     int numBroken;
00037     int packetsSent;
00038     int packetsRcvd;
00039     int bytesSent;
00040     int bytesRcvd;
00041 
00042   protected:
00046     virtual void initialize();
00047 
00052     virtual void handleMessage(cMessage *msg);
00053 
00059     virtual void finish();
00060 
00064     virtual void connect();
00065 
00067     virtual void close();
00068 
00070     virtual void sendPacket(int numBytes, int expectedReplyBytes, bool serverClose=false);
00071 
00073     virtual void setStatusString(const char *s);
00075 
00077     virtual void handleTimer(cMessage *msg) = 0;
00078 
00082     virtual void socketEstablished(int connId, void *yourPtr);
00083 
00088     virtual void socketDataArrived(int connId, void *yourPtr, cPacket *msg, bool urgent);
00089 
00091     virtual void socketPeerClosed(int connId, void *yourPtr);
00092 
00094     virtual void socketClosed(int connId, void *yourPtr);
00095 
00097     virtual void socketFailure(int connId, void *yourPtr, int code);
00098 
00100     virtual void socketStatusArrived(int connId, void *yourPtr, TCPStatusInfo *status) {delete status;}
00102 };
00103 
00104 #endif
00105 
00106