VR-Link API Documentation for HLA 1516
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 
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  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
DtU32 DtIpv4Addr
Definition: vlUtil.h:330
This file contains the declaration of DtMutex.
DT_DLL_NETCOMPAT void DtSetMaxPacketSize(int size)
Sets the maximum size for a packet to be sent through a DtSocket class.
DtSocket provides a low level interface for packet I/O with VR-Link applications. ...
Definition: vlSocket.h:110
This file contains the declaration of DtList and DtListItem.
std::vector< char > Buffer
Definition: vlSocket.h:234
DT_DLL_NETCOMPAT DtSocket * DtNewDfltSocket(int port, DtIpv4Addr destAddr=0, bool use_async=false)
DtTestOperator
Definition: vlSocket.h:65
error during flush
Definition: vlSocket.h:74
void setTest(DtTestOperator op, DtU32 value)
Definition: vlSocket.h:86
DtList values
Definition: vlSocket.h:100
Definition: vlSocket.h:68
int mySockFd
Definition: vlSocket.h:241
DtFilterTest()
Definition: vlSocket.h:82
int pkts_rcvd
Definition: vlSocket.h:198
DtFlushStatus
Definition: vlSocket.h:71
DtFilterTest myAddrFilter
Definition: vlSocket.h:256
std::map< DtIpv4Addr, Buffer > BufferMap
Definition: vlSocket.h:235
int myBlockingFlag
Definition: vlSocket.h:197
Definition: vlSocket.h:79
DtFilterTest myVersionFilter
Definition: vlSocket.h:253
void extendTest(DtU32 value)
Definition: vlSocket.h:87
int accept(int s, struct sockaddr *addr, int *addrlen)
DtList is deprecated, please use std::list&lt;T&gt;.
Definition: vlList.h:71
const DtIpv4Addr DtUSE_DEFAULT_IP_ADDR
Definition: vlSocket.h:54
= 0, buffered data remains to be flushed
Definition: vlSocket.h:75
instances of DtMutex are used to provide a platform independent mutual exclusion mechanism ...
Definition: vlMutex.h:31
Definition: vlSocket.h:65
Definition: vlSocket.h:65
DtTestOperator testOp
Definition: vlSocket.h:99
DT_DLL_NETCOMPAT int DtMaxPacketSize()
The maximum size for a packet, by default set to DtDEFAULT_MAX_PACKET_SIZE.
void reduceTest(DtU32 value)
Definition: vlSocket.h:88
Definition: vlSocket.h:68
DtFilterTest myExerciseFilter
Definition: vlSocket.h:254
DtFilterType
Definition: vlSocket.h:68
DtFilterTest myKindFilter
Definition: vlSocket.h:255
BufferMap myBufferMap
Definition: vlSocket.h:237
#define DT_DLL_NETCOMPAT
Definition: vlMachineTypes.h:111
int myBundlingFlag
Definition: vlSocket.h:239
Definition: vlSocket.h:73
unsigned long DtU32
A 32 bit unsigned integer value.
Definition: vlMachineTypes.h:153
provides basic Operating Independent Methods useful to a federate
virtual ~DtFilterTest()
Definition: vlSocket.h:83
int myMaxBundleSize
Definition: vlSocket.h:240
void disableTest()
Definition: vlSocket.h:85

Document ID: Generated on Wed Mar 27 02:04:30 EDT 2024 from SVN revision 264570
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)