19 #include <vlutil/vlInetSocket.h>
20 #include <vlutil/vlPrint.h>
34 DtMsgSocket(std::shared_ptr<DtMsgHeaderReader> hdrReader,
39 DtMsgSocket(DtUniquePtr<MAKRti::DtInetSocket> socket,
40 std::shared_ptr<DtMsgHeaderReader> hdrReader,
size_t recvBuffSize);
46 virtual int sendMessage(caddr_t msg,
size_t msgSize,
bool deleteAfterSend,
47 const MAKRti::DtInetAddr& destAddr = MAKRti::DtInetAddr::inaddrAny(),
int port = 0) = 0;
51 virtual bool flush() = 0;
54 virtual int recvMessage(caddr_t *buffptr) = 0;
58 virtual int recvMessageWithSrc(caddr_t *buffptr, MAKRti::DtInetEndpoint& src) = 0;
61 virtual bool closeSocket();
64 virtual MAKRti::DtInetSockState state()
const;
67 void printStateToStream(MAKRti::DtOutputStream& stream)
const;
70 const MAKRti::DtString& lastError()
const;
73 virtual void enableBundling(
size_t maxBundleSize) = 0;
76 virtual void disableBundling() = 0;
79 virtual void enableCompression(MAKRti::DtU8 compressionLevel) = 0;
82 virtual void disableCompression() = 0;
85 const MAKRti::DtInetEndpoint&
localEndpoint()
const {
return mySocket->localEndpoint(); }
94 MAKRti::DtU32
maxSendMsgSize()
const {
return mySocket->getSendBufferSize(); }
97 unsigned int descriptor()
const {
return mySocket->descriptor(); }
100 MAKRti::DtInetSocket* inetSocket();
111 void expandRecvBuffer(
size_t sizeNeeded );
131 MAKRti::DtInetSockState
state = MAKRti::DtInetSockState_NOT_INITIALIZED;
141 MAKRti::DtString stateStr =
"Socket State = ";
143 stream << stateStr.c_str() << std::endl;
146 stream <<
lastError().c_str() << std::endl;
159 div_t ratio = div( (
int)sizeNeeded, (
int)
myRecvBuffer.size() );
160 size_t newSize =
myRecvBuffer.size() * ( ratio.quot + 1 );
void setRecvBufferSize(MAKRti::DtU32 size)
Sets the socket receive buffer size.
Definition: msgSocket.h:91
unsigned int descriptor() const
Get's the socket file descriptor.
Definition: msgSocket.h:97
const MAKRti::DtInetEndpoint & localEndpoint() const
Gets the local endpoint for the socket.
Definition: msgSocket.h:85
virtual MAKRti::DtInetSockState state() const
Returns the state of the socket.
Definition: msgSocket.h:129
MAKRti::DtU32 maxSendMsgSize() const
Gets the maximum socket send size.
Definition: msgSocket.h:94
void expandRecvBuffer(size_t sizeNeeded)
Expands the receive buffer to accommodate the given size message.
Definition: msgSocket.h:155
MAKRti::DtString myLastError
Description of last error.
Definition: msgSocket.h:122
const MAKRti::DtString & lastError() const
Returns a description of the last error.
Definition: msgSocket.h:150
The DtMsgSocket provides a wrapper around the MAKRti::DtInetSocket class to operate on messages rathe...
Definition: msgSocket.h:28
std::shared_ptr< DtMsgHeaderReader > myHeaderReader
Reads data from message header.
Definition: msgSocket.h:125
DtUniquePtr< MAKRti::DtInetSocket > mySocket
The socket.
Definition: msgSocket.h:116
void setSendBufferSize(MAKRti::DtU32 size)
Sets the socket send buffer size.
Definition: msgSocket.h:88
MAKRti::DtInetBuffer myRecvBuffer
The buffer to store received data in.
Definition: msgSocket.h:119
The declaration of internal types.
void printStateToStream(MAKRti::DtOutputStream &stream) const
prints state to stream
Definition: msgSocket.h:139
#define DT_DLL_RTIUTIL
Definition: rtiMsConfig.h:160
MAKRti::DtInetSocket * inetSocket()
Returns a pointer to the MAKRti::DtInetSocket.
Definition: msgSocket.h:165