MAK RTIspy API Documentation for HLA 1.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
tcpMsgSocket.h
Go to the documentation of this file.
1 /*********************************************************************
2 ** Copyright (c) 2010 MaK Technologies, Inc.
3 ** All rights reserved.
4 *********************************************************************/
5 /*********************************************************************
6 ** $RCSfile: tcpMsgSocket.h,v $ $Revision: $ $State: Exp $
7 *********************************************************************/
8 
13 
14 #ifndef tcpMsgSocket_H_
15 #define tcpMsgSocket_H_
16 
17 #include "msgSocket.h"
18 #include "msgBundler.h"
19 #include "msgCompressor.h"
20 #include <list>
21 #include <vlutil/vlInetTcpSocket.h>
22 
23 using namespace MAKRti;
24 
26 {
27 public:
28  DtQueuedMsg() : msg(0), size(0), remainingMsg(0), remainingSize(0) {}
29  DtQueuedMsg(caddr_t m, size_t s) : msg(m), size(s),
30  remainingMsg(m), remainingSize(s) {}
32 
33  caddr_t msg;
34  size_t size;
35  caddr_t remainingMsg;
36  size_t remainingSize;
37 };
38 
43 {
44 public:
45 
49  DtTcpMsgSocket(DtBoost::shared_ptr<DtMsgHeaderReader> hdrReader,
50  size_t recvBufferSize = 20000, int maxQueuedMsgs = -1);
51 
54  DtTcpMsgSocket(std::auto_ptr<DtInetTcpSocket> socket,
55  DtBoost::shared_ptr<DtMsgHeaderReader> hdrReader,
56  size_t recvBuffSize = 20000, int maxQueuedMsgs = -1);
57 
59  virtual ~DtTcpMsgSocket();
60 
69  virtual void openServerSocket( DtU16 localPort,
70  DtU32 flags = DtDefaultSockOpts, DtInetDevice* hostIf = NULL,
71  DtInetUtils::DtInetAddrFamily family = DtInetUtils::DtInetAddrFamily_IPv4 );
72 
85  virtual void openClientSocket( const DtInetEndpoint& dest,
86  DtU32 flags = DtDefaultSockOpts, DtU16 localPort = 0,
87  DtInetDevice* hostIf = NULL);
88 
91  virtual int sendMessage(caddr_t msg, size_t msgSize, bool deleteAfterSend,
92  const DtInetAddr& destAddr = DtInetAddr::inaddrAny());
93 
96  virtual bool flush();
97 
99  virtual int recvMessage(caddr_t *buffptr);
100 
102  virtual int recvMessageWithSrc(caddr_t *buffptr, DtInetEndpoint& src);
103 
105  virtual void enableBundling(size_t maxBundleSize);
106 
108  virtual void disableBundling();
109 
111  virtual unsigned bundleSize() const;
112 
114  virtual void enableCompression(DtU8 compressionLevel);
115 
117  virtual void disableCompression();
118 
120  virtual unsigned compressionLevel() const;
121 
122  // Test the connection
123  virtual bool testConnectionStatus();
124 
127  virtual void setMaxQueuedMessages(int size);
128 
131  virtual int maxQueuedMessages() const;
132 
135  virtual bool getQueueStatus(int& percentFull) const;
136 
138  virtual void setTcpNoDelay(bool enable);
139 
141  virtual void setNonBlocking(bool nonBlocking);
142 
144  virtual const DtInetEndpoint& destination() const;
145 
147  virtual DtU32 maxMsgSize() const;
148 
150  DtInetTcpSocket* inetTcpSocket();
151 
153  bool isConnected() const { return mySocket.get() && mySocket->state() == DtInetSockState_CONNECTED; }
154 
156  bool isConnectionInProgress() const { return mySocket.get() && mySocket->state() == DtInetSockState_INPROGRESS; }
157 
158 protected:
159 
161  virtual int sendData(caddr_t msg, size_t msgSize, bool deleteAfterSend);
162 
165  virtual bool flushQueue();
166 
168  virtual bool queueMessage(caddr_t msg, size_t msgSize);
169 
171  virtual void resizeTestPacket();
172 
173 protected:
174 
178 
181 
184 
186  DtInetBuffer myTestPacket;
187 
189  std::list<DtQueuedMsg> myMsgQueue;
190 
193 
196 
199 
202 
205 
210 
213 };
214 
215 inline DtInetTcpSocket* DtTcpMsgSocket::inetTcpSocket()
216 {
217  return static_cast<DtInetTcpSocket*>(mySocket.get());
218 }
219 
220 #endif

Document ID: Generated on Wed Mar 11 20:26:49 EDT 2015 from SVN revision 150939
Copyright © 2005-2015 VT MÄK Inc. All Rights Reserved (www.mak.com)