VR-Link API Documentation for DIS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
vlInetTcpSocket.h
Go to the documentation of this file.
1 /*********************************************************************
2 ** Copyright (c) 1992-2010 VT MAK
3 ** All rights reserved.
4 *********************************************************************/
9 #pragma once
10 
11 #include <vlutil/vlInetSocket.h>
12 
13 #ifdef DtUSE_UTILITIES_NAMESPACE
14 namespace DtUSE_UTILITIES_NAMESPACE
15 {
16 #endif
17 
18 class DtInetTcpSockPimpl;
19 
24 {
25 public:
28 
44  DtInetTcpSocket( DtU16 localPort, DtInetDevice* hostIf = NULL,
46  DtU32 flags = DtSockOptNoDelay, bool immediateOpen = true );
47 
75  DtInetTcpSocket( const DtInetEndpoint& dest, DtU16 localPort = 0,
76  DtInetDevice* hostIf = NULL, DtU32 flags = DtDefaultSockOpts,
77  bool immediateOpen = true );
78 
80  virtual ~DtInetTcpSocket();
81 
88  virtual bool setDestination( const DtInetEndpoint& addr );
89 
94  virtual bool openSocket();
95 
99  virtual bool closeSocket();
100 
108  virtual bool bindToDevice( const DtInetDevice* hostIf = NULL );
109 
111  virtual bool listenForConnections();
112 
122  virtual bool acceptConnection( DtInetTcpSocket* peer,
123  DtU32 flags = DtDefaultSockOpts);
124 
131  virtual bool connectToDestination();
132 
140  virtual int send( caddr_t packet, size_t size, DtU32 flags = 0 );
141  virtual int sendTo( caddr_t packet, size_t size,
142  DtInetEndpoint& dest, DtU32 flags = 0 );
143 
144  virtual int sendChain( DtInetBufferChain& packets, DtU32 flags = 0 );
145  virtual int sendChainTo( DtInetBufferChain& packets,
146  DtInetEndpoint& dest, DtU32 flags = 0 );
148 
157 
162  virtual DtInetSockRcvStatus recv( caddr_t buff, size_t buffSize,
163  DtU32 flags = 0 );
168  virtual DtInetSockRcvStatus recvToChain( DtInetBufferChain& packets,
169  DtU32 flags = 0 );
174  virtual DtInetSockRcvStatus recvFrom( caddr_t buff, size_t buffSize,
175  DtInetEndpoint& src,
176  DtU32 flags = 0 );
177  virtual DtInetSockRcvStatus recvToChainFrom( DtInetBufferChain& packets,
178  DtInetEndpoint& src,
179  DtU32 flags = 0 );
181 
186  virtual bool setSocket( const DtInetEndpoint& dest, DtU16 localPort = 0,
187  DtInetDevice* hostIf = NULL, DtU32 flags = DtDefaultSockOpts );
188 
195  virtual bool isOk();
196 
198  virtual unsigned descriptor() const;
199 
204  virtual bool setNonBlockingOption( bool onOrOff );
205  virtual bool setReuseAddressOption( bool onOrOff );
206  virtual bool setSendBufferSize( DtU32 size );
207  virtual bool setReceiveBufferSize( DtU32 size );
208  virtual bool setDoNotRouteOption( bool onOrOff );
209  virtual bool setSendLowWatermark( DtU32 size );
210  virtual bool setReceiveLowWatermark( DtU32 size );
211  virtual bool setTcpNoDelayOption( bool onOrOff );
212  virtual bool setTcpLingerOption( DtU16 timeout );
213  virtual bool setConnAbortedOption( bool onOrOff );
214  virtual bool setTcpKeepAliveOption( bool onOrOff );
215 
216  virtual DtU32 getSendBufferSize();
217  virtual DtU32 getReceiveBufferSize();
218  virtual DtU32 getBytesAvailable();
219  virtual bool getReuseAddressOption();
220  virtual bool getDoNotRouteOption();
221  virtual DtU32 getSendLowWatermark();
222  virtual DtU32 getReceiveLowWatermark();
223  virtual bool getTcpLingerOption( DtU16& timeout );
224  virtual bool getConnAbortedOption();
225  virtual bool getTcpKeepAliveOption();
227 
228 protected:
231  virtual bool initAcceptedConnection( const DtInetAddr& localAddr, DtU16 localPort,
232  DtU32 flags = DtDefaultSockOpts );
236  virtual bool openAcceptedConnection( DtInetEndpoint peer );
237 
240  virtual void* tcpSocket();
241  virtual void* tcpServerSocket();
242 
244  bool isServerSock() const;
245 
246 private:
248  DtInetTcpSocket( const DtInetTcpSocket& orig );
249 
251  DtInetTcpSocket& operator=(const DtInetTcpSocket& orig);
252 
254  friend class DtInetTcpSockPimpl;
255  DtInetTcpSockPimpl* myAsyncPimpl;
256 
257 protected:
258  void* myIoService;
259  void* myTcpSocket;
260  void* myTcpAcceptor; // server sockets only
261 
262  // This member should only be used by 'server' sockets. All other sockets
263  // should set this to DtInetUtils::DtInetAddrFamily_INVALID to differentiate
264  // server and client sockets.
266 };
267 // end of class DtInetTcpSocket
268 
269 #ifdef DtUSE_UTILITIES_NAMESPACE
270 }
271 #endif
272 
273 
274 

Document ID: Generated on Mon Apr 8 04:49:21 EDT 2019 from SVN revision 197403
Copyright © 2005-2016 VT MÄK. All Rights Reserved (www.mak.com)