00001 /* 00002 * wlanmodel/cUDPSocketRTScheduler.h 00003 * 00004 * Copyright (C) 2008-2009 Reto Gantenbein 00005 * 00006 * This program is free software; you can redistribute it and/or modify 00007 * it under the terms of the GNU General Public License version 2 as 00008 * published by the Free Software Foundation. 00009 */ 00010 00011 #ifndef __CUDPSOCKETRTSCHEDULER_H__ 00012 #define __CUDPSOCKETRTSCHEDULER_H__ 00013 00014 #include <cerrno> 00015 #include <omnetpp.h> 00016 #include <platdep/timeutil.h> 00017 #include <platdep/sockets.h> 00018 00020 class cUDPSocketRTScheduler : public cScheduler 00021 { 00022 protected: 00023 // config 00024 int port; 00025 cModule *module; 00026 cMessage *notificationMsg; 00027 char *recvBuffer; 00028 int recvBufferSize; 00029 int *numBytesPtr; 00030 00031 // state 00032 timeval baseTime; 00033 SOCKET listenerSocket; 00034 SOCKET connSocket; 00035 00036 virtual void setupListener(); 00037 virtual bool receiveWithTimeout(long usec); 00038 virtual int receiveUntil(const timeval& targetTime); 00039 00040 public: 00042 cUDPSocketRTScheduler(); 00043 00045 virtual ~cUDPSocketRTScheduler(); 00046 00048 virtual void startRun(); 00049 00051 virtual void endRun(); 00052 00054 virtual void executionResumed(); 00055 00059 virtual void setInterfaceModule(cModule *module, 00060 cMessage *notificationMsg, 00061 char *recvBuffer, 00062 int recvBufferSize, 00063 int *numBytesPtr); 00064 00066 virtual cMessage *getNextEvent(); 00067 00069 int sendMessage(const char *msg, 00070 const size_t numBytes, 00071 const sockaddr *nodeAddr, 00072 const socklen_t addrSize); 00073 }; 00074 00075 #endif