18 #include <vlutil/vlInetSocket.h>
19 #include <vlutil/vlPrint.h>
24 using namespace MAKRti;
35 DtMsgSocket(DtBoost::shared_ptr<DtMsgHeaderReader> hdrReader,
41 DtBoost::shared_ptr<DtMsgHeaderReader> hdrReader,
size_t recvBuffSize);
47 virtual int sendMessage(caddr_t msg,
size_t msgSize,
bool deleteAfterSend,
48 const DtInetAddr& destAddr = DtInetAddr::inaddrAny(),
int port = 0) = 0;
52 virtual bool flush() = 0;
55 virtual int recvMessage(caddr_t *buffptr) = 0;
59 virtual int recvMessageWithSrc(caddr_t *buffptr, DtInetEndpoint& src) = 0;
62 virtual bool closeSocket();
65 virtual DtInetSockState state()
const;
68 void printStateToStream(MAKRti::DtOutputStream& stream)
const;
71 const DtString& lastError()
const;
74 virtual void enableBundling(
size_t maxBundleSize) = 0;
77 virtual void disableBundling() = 0;
80 virtual void enableCompression(DtU8 compressionLevel) = 0;
83 virtual void disableCompression() = 0;
86 const DtInetEndpoint&
localEndpoint()
const {
return mySocket->localEndpoint(); }
98 unsigned int descriptor()
const {
return mySocket->descriptor(); }
101 DtInetSocket* inetSocket();
112 void expandRecvBuffer(
size_t sizeNeeded );
132 DtInetSockState state = DtInetSockState_NOT_INITIALIZED;
135 state = mySocket->state();
142 MAKRti::DtString stateStr =
"Socket State = ";
144 stream << stateStr.c_str() << std::endl;
145 if (!lastError().isEmpty())
147 stream << lastError().c_str() << std::endl;
158 if(sizeNeeded > myRecvBuffer.size())
160 div_t ratio = div( (
int)sizeNeeded, (
int)myRecvBuffer.size() );
161 size_t newSize = myRecvBuffer.size() * ( ratio.quot + 1 );
162 myRecvBuffer.resize(newSize);
168 return mySocket.get();
DtU32 maxSendMsgSize() const
Gets the maximum socket send size.
Definition: msgSocket.h:95
virtual DtInetSockState state() const
Returns the state of the socket.
Definition: msgSocket.h:130
DtString myLastError
Description of last error.
Definition: msgSocket.h:123
DtInetBuffer myRecvBuffer
The buffer to store received data in.
Definition: msgSocket.h:120
DtBoost::shared_ptr< DtMsgHeaderReader > myHeaderReader
Reads data from message header.
Definition: msgSocket.h:126
const DtString & lastError() const
Returns a description of the last error.
Definition: msgSocket.h:151
unsigned int descriptor() const
Get's the socket file descriptor.
Definition: msgSocket.h:98
DtInetSocket * inetSocket()
Returns a pointer to the DtInetSocket.
Definition: msgSocket.h:166
void expandRecvBuffer(size_t sizeNeeded)
Expands the receive buffer to accommodate the given size message.
Definition: msgSocket.h:156
void setRecvBufferSize(DtU32 size)
Sets the socket receive buffer size.
Definition: msgSocket.h:92
const DtInetEndpoint & localEndpoint() const
Gets the local endpoint for the socket.
Definition: msgSocket.h:86
The DtMsgSocket provides a wrapper around the DtInetSocket class to operate on messages rather than j...
Definition: msgSocket.h:29
std::auto_ptr< MAKRti::DtInetSocket > mySocket
The socket.
Definition: msgSocket.h:117
void printStateToStream(MAKRti::DtOutputStream &stream) const
prints state to stream
Definition: msgSocket.h:140
#define DT_DLL_RTIUTIL
Definition: rtiMsConfig.h:127
void setSendBufferSize(DtU32 size)
Sets the socket send buffer size.
Definition: msgSocket.h:89