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 
89  virtual DtInetTcpSocket* reconnect();
90  virtual void replaceSocket(std::auto_ptr<DtInetTcpSocket> newSock);
91 
94  virtual int sendMessage(caddr_t msg, size_t msgSize, bool deleteAfterSend,
95  const DtInetAddr& destAddr = DtInetAddr::inaddrAny(), int port = 0);
96 
99  virtual bool flush();
100 
102  virtual int recvMessage(caddr_t *buffptr);
103 
105  virtual int recvMessageWithSrc(caddr_t *buffptr, DtInetEndpoint& src);
106 
108  virtual void enableBundling(size_t maxBundleSize);
109 
111  virtual void disableBundling();
112 
114  virtual unsigned bundleSize() const;
115 
117  virtual void enableCompression(DtU8 compressionLevel);
118 
120  virtual void disableCompression();
121 
123  virtual unsigned compressionLevel() const;
124 
125  // Test the connection
126  virtual bool testConnectionStatus();
127 
130  virtual void setMaxQueuedMessages(int size);
131 
134  virtual int maxQueuedMessages() const;
135 
138  virtual bool getQueueStatus(int& percentFull) const;
139 
141  virtual void setTcpNoDelay(bool enable);
142 
144  virtual void setNonBlocking(bool nonBlocking);
145 
147  virtual const DtInetEndpoint& destination() const;
148 
150  virtual DtU32 maxMsgSize() const;
151 
153  DtInetTcpSocket* inetTcpSocket();
154 
156  bool isConnected() const { return mySocket.get() && mySocket->state() == DtInetSockState_CONNECTED; }
157 
159  bool isConnectionInProgress() const { return mySocket.get() && mySocket->state() == DtInetSockState_INPROGRESS; }
160 
161  MAKRti::DtString getErrorString() const;
162 
163  virtual bool isClient() const;
164 
165 protected:
166 
168  virtual int sendData(caddr_t msg, size_t msgSize, bool deleteAfterSend);
169 
172  virtual bool flushQueue();
173 
175  virtual bool queueMessage(caddr_t msg, size_t msgSize);
176 
178  virtual void resizeTestPacket();
179 
180 protected:
181 
185 
188 
191 
193  DtInetBuffer myTestPacket;
194 
196  std::list<DtQueuedMsg> myMsgQueue;
197 
200 
203 
206 
209 
212 
217 
220 
222 
223  // These are client connection related params required for reconnection
224  DtInetEndpoint myClientDestination;
227  std::auto_ptr<DtInetDevice> myClientHostIf;
228 
229 };
230 
231 inline DtInetTcpSocket* DtTcpMsgSocket::inetTcpSocket()
232 {
233  return static_cast<DtInetTcpSocket*>(mySocket.get());
234 }
235 
236 #endif
~DtQueuedMsg()
Definition: tcpMsgSocket.h:31
bool isConnectionInProgress() const
Returns true if the socket is in the process of connecting.
Definition: tcpMsgSocket.h:159
DtU16 myClientLocalPort
Definition: tcpMsgSocket.h:226
size_t myBytesNeededForSize
The number of bytes needed to read the size from the message header.
Definition: tcpMsgSocket.h:219
std::list< DtQueuedMsg > myMsgQueue
The queue of unsent messages.
Definition: tcpMsgSocket.h:196
DtInetBuffer myTestPacket
The buffer to store test packets in.
Definition: tcpMsgSocket.h:193
This file contains the declaration of the DtMsgCompressor class.
DtInetEndpoint myClientDestination
Definition: tcpMsgSocket.h:224
size_t myNumBytesToWaitFor
The number of bytes we are waiting for to complete the message.
Definition: tcpMsgSocket.h:187
DtMsgBundler myMsgBundler
Bundler for outgoing messages.
Definition: tcpMsgSocket.h:199
DtU32 myClientFlags
Definition: tcpMsgSocket.h:225
DtQueuedMsg(caddr_t m, size_t s)
Definition: tcpMsgSocket.h:29
The DtMsgCompressor class provides a means for compressing and uncompressing messages.
Definition: msgCompressor.h:31
bool myNeedSize
Whether we still need to receive the size field for the next/current message.
Definition: tcpMsgSocket.h:184
int myMutableOldQueueLevel
The queue level the last time the user was notified of queue state.
Definition: tcpMsgSocket.h:216
DtInetTcpSocket * inetTcpSocket()
Returns a pointer to the DtInetTcpSocket.
Definition: tcpMsgSocket.h:231
int myMaxQueuedMessages
The maximum size the send queue is allowed to reach.
Definition: tcpMsgSocket.h:211
size_t size
Definition: tcpMsgSocket.h:34
#define NULL
Definition: baseTypes13.h:8
This file contains the declaration of the DtMsgSocket base class.
bool myIsClient
Definition: tcpMsgSocket.h:221
std::auto_ptr< DtInetDevice > myClientHostIf
Definition: tcpMsgSocket.h:227
DtQueuedMsg()
Definition: tcpMsgSocket.h:28
The DtMsgBundler class provides a means for bundling and unbundling messages.
Definition: msgBundler.h:26
The DtTcpMsgSocket class provides an address family independent TCP socket that handles RTI messages...
Definition: tcpMsgSocket.h:42
This file contains the declaration of the DtMsgBundler class.
int myNumBytesReceived
The number of bytes we have so far received for the current message.
Definition: tcpMsgSocket.h:190
bool isConnected() const
Returns true if the socket is connected.
Definition: tcpMsgSocket.h:156
The DtMsgSocket provides a wrapper around the DtInetSocket class to operate on messages rather than j...
Definition: msgSocket.h:29
bool myCompressionEnabled
Whether message compression is enabled.
Definition: tcpMsgSocket.h:208
size_t remainingSize
Definition: tcpMsgSocket.h:36
DtMsgCompressor myMsgCompressor
Message compressor and uncompressor.
Definition: tcpMsgSocket.h:205
Definition: tcpMsgSocket.h:25
caddr_t remainingMsg
Definition: tcpMsgSocket.h:35
#define DT_DLL_RTIUTIL
Definition: rtiMsConfig.h:127
bool myBundlingEnabled
Whether message bundling is enabled.
Definition: tcpMsgSocket.h:202
caddr_t msg
Definition: tcpMsgSocket.h:33

Document ID: Generated on Thu May 11 15:55:32 EDT 2023 from SVN revision 254743
Copyright © 2005-2020 MAK Technologies Inc. All Rights Reserved (www.mak.com)