VR-Link API Documentation for DIS
vlSocket.h
Go to the documentation of this file.
1 /*********************************************************************
2 ** Copyright (c) 1992, 1997 MaK Technologies, Inc.
3 ** All rights reserved.
4 *********************************************************************/
5 /*********************************************************************
6 ** $RCSfile: vlSocket.h,v $ $Revision: 1.2.6.2 $ $State: Exp $
7 *********************************************************************/
8 #ifndef vlSocket_H_
9 #define vlSocket_H_
10 
15 #include <vlutil/vlConfig.h>
16 #include <vlutil/vlUtil.h>
17 #include <vlutil/vlList.h>
18 #include <vlutil/vlMutex.h>
19 
20 #if DT_HAVE_STD_H
21 #include <std.h>
22 #endif
23 
24 #include <stdio.h>
25 #include <sys/types.h>
26 #include <map>
27 #include <vector>
28 
29 struct ifconf;
30 
31 #ifdef DtUSE_UTILITIES_NAMESPACE
32 namespace DtUSE_UTILITIES_NAMESPACE
33 {
34 #endif
35 
36 
44 
48 #define DtDEFAULT_MAX_PACKET_SIZE 15000
49 #define DtDEFAULT_PORT 3000
50 
51 #ifdef DtUSE_UTILITIES_NAMESPACE
53 #else
55 #endif
56 
57 #define DtSOCKET_PACKET 1
58 #define DtSOCKET_NO_PACKET 0
59 #define DtSOCKET_SERVER_MSG -1
60 #define DtSOCKET_FILTERED_PACKET -2
61 #define DtSOCKET_FILTERED_BY_PORT -3
62 
63 
66 
69 
72 {
73  DtFlushError = -1,
76 };
77 
80 {
81  public:
82  DtFilterTest() { disableTest();}
83  virtual ~DtFilterTest() {}
84 
85  void disableTest() { setTest(Dto_NEQ, 0, 0); }
86  void setTest(DtTestOperator op, DtU32 value) { setTest(op, 1, &value); }
87  void extendTest(DtU32 value) { extendTest (1, &value); }
88  void reduceTest(DtU32 value) { reduceTest (1, &value); }
89  virtual void setOperator(DtTestOperator op);
90  virtual void setTest(DtTestOperator op, int n, DtU32 *values);
91  virtual void extendTest(int n, DtU32 *values);
92  virtual void reduceTest(int n, DtU32 *values);
93 
94  virtual bool evalTest(char *buf, int offset, DtFilterType type);
95 
96  protected:
97 
98  virtual void clearList();
101 };
102 
111 {
112  public:
113 
115  DtSocket();
116 
118  virtual ~DtSocket();
119 
128  virtual int DtSend(caddr_t packet, size_t size,
130 
134  virtual int sendTo(caddr_t packet, size_t size,
135  DtIpv4Addr addr = DtUSE_DEFAULT_IP_ADDR) = 0;
136 
150  virtual int DtRecv(caddr_t *buffptr, int *status=0) = 0;
151 
153  virtual int DtRecv(caddr_t buff, size_t) = 0;
155  caddr_t DtRecv();
156 
159  virtual DtFlushStatus flush();
160 
164  virtual DtFlushStatus flush(long& byteCount);
165 
170  virtual void setReceiveBufferSize(int newsize);
171 
175  virtual void setSendBufferSize(int newsize);
176 
177  virtual void setBundling(int maxSize);
178  virtual int isBundling();
179  virtual void setUnbundling(int);
180 
181  virtual DtIpv4Addr lastSourceInetAddr();
182  virtual int DtReportPktsRcvd(void);
183  virtual void DtBecomeNonBlocking(void);
184  virtual void notifyMe();
185 
186  virtual int listenToMulticastGroup(DtIpv4Addr addr, DtIpv4Addr netInterface = DtUSE_DEFAULT_IP_ADDR);
187  virtual int dropMulticastGroup(DtIpv4Addr addr, DtIpv4Addr netInterface = DtUSE_DEFAULT_IP_ADDR);
188  virtual int setMcastTtl(int);
189  virtual void setMcastDevice(DtIpv4Addr);
190 
191  virtual DtFilterTest *exerciseId();
192  virtual DtFilterTest *protocolVersion();
193  virtual DtFilterTest *pduKind();
194  virtual DtFilterTest *ipAddr();
195 
196 
199 
204  virtual int readFd();
205  virtual int writeFd();
206  virtual bool isOk() const;
207 
208  static void initializeNetwork();
209 
210 
212  static void setQuietSockets(bool quietVal);
213  static bool areQuietSockets();
214 
215  protected:
216 
217 #ifdef _WIN32
218  static void winInit();
219  static void winClose();
220  static int theWindowsInitializedCount;
221  static DtMutex theWindowsInitMutex;
222 #endif
223 
224  static bool theAreQuietSockets;
225 
228  static int getConfig(const char* device, int sock, ifconf* ifc);
229 
230  protected:
231 
232  virtual bool accept(char *buf, DtIpv4Addr iaddr);
233 
234  typedef std::vector<char> Buffer;
235  typedef std::map<DtIpv4Addr, Buffer> BufferMap;
236 
238 
241  int mySockFd;
242 
243 
244  private:
246  DtSocket(const DtSocket &);
247 
249  DtSocket &operator=(const DtSocket &);
250 
251  private:
252 
257 };
258 
260 DT_DLL_NETCOMPAT DtSocket *DtNewDfltSocket(int port, DtIpv4Addr destAddr = 0,
261  bool use_async = false);
267 
271 DT_DLL_NETCOMPAT void DtSetMaxPacketSize(int size);
272 
273 #ifdef DtUSE_UTILITIES_NAMESPACE
274 }
275 #endif
276 
277 #define vlSocket_inl_
278 #include "vlSocket.inl"
279 #undef vlSocket_inl_
280 
281 #endif

Document ID: Generated on Wed Oct 23 22:25:48 EDT 2013 from SVN revision 132765
Copyright © 2005-2013 VT MÄK. All Rights Reserved (www.mak.com)