![]() |
VR-Link API Documentation for HLA 1516
|
00001 /********************************************************************* 00002 ** Copyright (c) 1992-2010 VT MAK 00003 ** All rights reserved. 00004 *********************************************************************/ 00009 #pragma once 00010 00011 #include <vlutil/vlInetSocket.h> 00012 00013 #ifdef DtUSE_UTILITIES_NAMESPACE 00014 namespace DtUSE_UTILITIES_NAMESPACE 00015 { 00016 #endif 00017 00018 class DtInetTcpSockPimpl; 00019 00023 class DT_DLL_VLUTIL DtInetTcpSocket : public DtInetSocket 00024 { 00025 public: 00027 DtInetTcpSocket(); 00028 00044 DtInetTcpSocket( DtU16 localPort, DtInetDevice* hostIf = NULL, 00045 DtInetUtils::DtInetAddrFamily family = DtInetUtils::DtInetAddrFamily_IPv4, 00046 DtU32 flags = DtSockOptNoDelay, bool immediateOpen = true ); 00047 00075 DtInetTcpSocket( const DtInetEndpoint& dest, DtU16 localPort = 0, 00076 DtInetDevice* hostIf = NULL, DtU32 flags = DtDefaultSockOpts, 00077 bool immediateOpen = true ); 00078 00080 virtual ~DtInetTcpSocket(); 00081 00088 virtual bool setDestination( const DtInetEndpoint& addr ); 00089 00094 virtual bool openSocket(); 00095 00099 virtual bool closeSocket(); 00100 00108 virtual bool bindToDevice( const DtInetDevice* hostIf = NULL ); 00109 00111 virtual bool listenForConnections(); 00112 00122 virtual bool acceptConnection( DtInetTcpSocket* peer, 00123 DtU32 flags = DtDefaultSockOpts); 00124 00131 virtual bool connectToDestination(); 00132 00140 virtual int send( caddr_t packet, size_t size, DtU32 flags = 0 ); 00141 virtual int sendTo( caddr_t packet, size_t size, 00142 DtInetEndpoint& dest, DtU32 flags = 0 ); 00143 00144 virtual int sendChain( DtInetBufferChain& packets, DtU32 flags = 0 ); 00145 virtual int sendChainTo( DtInetBufferChain& packets, 00146 DtInetEndpoint& dest, DtU32 flags = 0 ); 00148 00157 00162 virtual DtInetSockRcvStatus recv( caddr_t buff, size_t buffSize, 00163 DtU32 flags = 0 ); 00168 virtual DtInetSockRcvStatus recvToChain( DtInetBufferChain& packets, 00169 DtU32 flags = 0 ); 00174 virtual DtInetSockRcvStatus recvFrom( caddr_t buff, size_t buffSize, 00175 DtInetEndpoint& src, 00176 DtU32 flags = 0 ); 00177 virtual DtInetSockRcvStatus recvToChainFrom( DtInetBufferChain& packets, 00178 DtInetEndpoint& src, 00179 DtU32 flags = 0 ); 00181 00186 virtual bool setSocket( const DtInetEndpoint& dest, DtU16 localPort = 0, 00187 DtInetDevice* hostIf = NULL, DtU32 flags = DtDefaultSockOpts ); 00188 00195 virtual bool isOk(); 00196 00198 virtual int descriptor() const; 00199 00204 virtual bool setNonBlockingOption( bool onOrOff ); 00205 virtual bool setReuseAddressOption( bool onOrOff ); 00206 virtual bool setSendBufferSize( DtU32 size ); 00207 virtual bool setReceiveBufferSize( DtU32 size ); 00208 virtual bool setDoNotRouteOption( bool onOrOff ); 00209 virtual bool setSendLowWatermark( DtU32 size ); 00210 virtual bool setReceiveLowWatermark( DtU32 size ); 00211 virtual bool setTcpNoDelayOption( bool onOrOff ); 00212 virtual bool setTcpLingerOption( DtU16 timeout ); 00213 virtual bool setConnAbortedOption( bool onOrOff ); 00214 virtual bool setTcpKeepAliveOption( bool onOrOff ); 00215 00216 virtual DtU32 getSendBufferSize(); 00217 virtual DtU32 getReceiveBufferSize(); 00218 virtual DtU32 getBytesAvailable(); 00219 virtual bool getReuseAddressOption(); 00220 virtual bool getDoNotRouteOption(); 00221 virtual DtU32 getSendLowWatermark(); 00222 virtual DtU32 getReceiveLowWatermark(); 00223 virtual bool getTcpLingerOption( DtU16& timeout ); 00224 virtual bool getConnAbortedOption(); 00225 virtual bool getTcpKeepAliveOption(); 00227 00228 protected: 00231 virtual bool initAcceptedConnection( const DtInetAddr& localAddr, DtU16 localPort, 00232 DtU32 flags = DtDefaultSockOpts ); 00236 virtual bool openAcceptedConnection( DtInetEndpoint peer ); 00237 00240 virtual void* tcpSocket(); 00241 virtual void* tcpServerSocket(); 00242 00244 bool isServerSock() const; 00245 00246 private: 00248 DtInetTcpSocket( const DtInetTcpSocket& orig ); 00249 00251 DtInetTcpSocket& operator=(const DtInetTcpSocket& orig); 00252 00254 friend class DtInetTcpSockPimpl; 00255 DtInetTcpSockPimpl* myAsyncPimpl; 00256 00257 protected: 00258 void* myIoService; 00259 void* myTcpSocket; 00260 void* myTcpAcceptor; // server sockets only 00261 00262 // This member should only be used by 'server' sockets. All other sockets 00263 // should set this to DtInetUtils::DtInetAddrFamily_INVALID to differentiate 00264 // server and client sockets. 00265 DtInetUtils::DtInetAddrFamily myAddrFamily; 00266 }; 00267 // end of class DtInetTcpSocket 00268 00269 #ifdef DtUSE_UTILITIES_NAMESPACE 00270 } 00271 #endif 00272 00273 00274