![]() |
VR-Link API Documentation for DIS
|
00001 /********************************************************************* 00002 ** Copyright (c) 1993, 1994, 1995, 1997 MaK Technologies, Inc. 00003 ** All rights reserved. 00004 *********************************************************************/ 00005 /********************************************************************* 00006 ** $RCSfile: vlClientSocket.h,v $ $Revision: 1.2.6.1 $ $State: Exp $ 00007 *********************************************************************/ 00008 #ifndef vlClientSocket_H_ 00009 #define vlClientSocket_H_ 00010 00014 00015 #include <vlutil/vlNetTypes.h> 00016 #include "vlSocket.h" 00017 #include "vlNetSocket.h" 00018 #include <vlutil/vlCliServer.h> 00019 00020 #ifdef DtUSE_UTILITIES_NAMESPACE 00021 namespace DtUSE_UTILITIES_NAMESPACE 00022 { 00023 #endif 00024 00025 #if DT_HAVE_DAEMON 00026 class DT_DLL_NETCOMPAT DtCsFilterTest : public DtFilterTest 00027 { 00028 public: 00029 DtCsFilterTest(int fd, DtU8 filterType, DtU32 clientId); 00030 virtual ~DtCsFilterTest(); 00031 00032 void setOperator(DtTestOperator op); 00033 void extendTest(int n, DtU32 *values); 00034 void reduceTest(int n, DtU32 *vals); 00036 bool evalTest(char *, int , DtFilterType){return true;} 00037 00038 private: 00039 DtCsFilterMsg filterMsg; 00040 }; 00041 #endif 00042 00043 #define DtCsFlagsDefault (DtCsFlagsReadWrite | DtCsFlagsServerChooseDropMode ) 00044 #define DtCsQDefaultSize DtCsUseDefaultSize 00045 00054 class DT_DLL_NETCOMPAT DtClientSocket : public DtSocket 00055 { 00056 public: 00057 00058 DtClientSocket(int port, int recvQSize = 00059 DtCsQDefaultSize, unsigned short csFlags = DtCsFlagsDefault); 00060 00061 DtClientSocket(int port, DtIpv4Addr destAddr, int recvQSize = 00062 DtCsQDefaultSize, unsigned short csFlags = DtCsFlagsDefault); 00063 00064 ~DtClientSocket(); 00065 00066 int sendTo(caddr_t packet, size_t size, DtIpv4Addr addr); 00067 00068 int DtRecv(caddr_t, size_t); 00069 int DtRecv(caddr_t *buffptr, int *status=NULL); 00070 00071 int listenToMulticastGroup(DtIpv4Addr multicastAddr); 00072 int dropMulticastGroup(DtIpv4Addr multicastAddr); 00073 int setMcastTtl(int ttl) { return netSock->setMcastTtl(ttl); } 00074 00075 void setUnbundling(int onOff); 00078 00079 DtIpv4Addr lastSourceInetAddr() { return sourceAddr; } 00080 void DtBecomeNonBlocking(void); 00081 00082 int readFd() { return recvFd; } 00083 int writeFd() { return sendFd; } 00084 virtual bool isOk() const; 00085 bool isInternal(); 00086 00087 void setPsMsgTimeout(int seconds); 00088 00089 void notifyMe(); 00090 void disconnectFromServer(); 00091 void setPacketServerInternal(); 00092 void setPacketServerExternal(); 00093 void pingClients(); 00094 void testClients(); 00095 void terminatePacketServer(); 00096 void requestServerState(); 00097 void requestServerCStates(); 00098 void setPacketServerUnbundling(int onOff); 00099 00100 #if DT_HAVE_DAEMON 00101 DtFilterTest *exerciseId() { return exercise; } 00102 DtFilterTest *protocolVersion() { return version; } 00103 DtFilterTest *pduKind() { return kind; } 00104 DtFilterTest *ipAddr() { return addr; } 00105 #endif 00106 00107 DtTime psMsgTimeout; 00108 00109 protected: 00110 00111 void init(int port, DtIpv4Addr destAddr, int recvQSize, 00112 unsigned short csFlags); 00113 00114 int timedRecv(caddr_t buf, size_t size, char *psKind); 00115 void drainNotifySocket(); 00116 void checkGoAway(); 00117 00118 #if DT_HAVE_DAEMON 00119 DtShmMsgQueueReader *reader; 00120 #endif 00121 00122 DtNetSocket *netSock; 00123 bool notifyPending; 00124 00125 bool myOkFlag; 00126 int recvFd; 00127 int sendFd; 00128 long clientId; 00129 00130 private: 00131 00132 void processControlMsg(DtCsMsg *msg); 00133 DtCsMsg *getPsMsg (DtCsMsg *buf, char desiredKind); 00134 void cleanup(void); 00135 00136 #if DT_HAVE_DAEMON 00137 DtCsFilterTest *exercise; 00138 DtCsFilterTest *version; 00139 DtCsFilterTest *kind; 00140 DtCsFilterTest *addr; 00141 #endif 00142 00143 DtIpv4Addr destAddr; 00144 char clientSocketPath[DtCsClientPathSize]; 00145 int serverPort; 00146 bool internal; 00147 DtIpv4Addr sourceAddr; 00148 DtNetFloat64* pktBuff8; 00149 00150 char *shmAddr; 00151 #if DT_HAVE_DAEMON 00152 DtCsControlReqMsg *controlMsg; 00153 #endif 00154 }; 00155 00156 inline bool DtClientSocket::isOk() const 00157 { 00158 return myOkFlag; 00159 } 00160 00161 #ifdef DtUSE_UTILITIES_NAMESPACE 00162 } 00163 #endif 00164 00165 #endif /* _CLIENTSOCKET_H_ */