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 
This file contains the declaration of the DtInetSocket base class.
Definition: vlInetAddrUtils.h:58
DtInetSockRcvStatus
Socket state enumeration.
Definition: vlInetSocket.h:129
std::vector< DtInetBuffer * > DtInetBufferChain
Socket state enumeration.
Definition: vlInetSocket.h:105
The DtInetSocket class provides a protocol independant, address family independant base class for TCP...
Definition: vlInetSocket.h:201
int recv(int s, char *buf, int bufLen, int flags)
#define DtSockOptNoDelay
Tell TCP sockets to disable Nagle packet coalescing and enables TCP_NODELAY operation.
Definition: vlInetSocket.h:65
DtInetTcpSockPimpl * myAsyncPimpl
Definition: vlInetTcpSocket.h:255
DtInetAddrFamily
Definition: vlInetAddrUtils.h:55
The DtInetEndpoint class provides a protocol independant, address family independent mechanism to rep...
Definition: vlInetEndpoint.h:33
Represents a IPv4 or IPv6 address.
Definition: vlInetAddr.h:36
Definition: vlInetDevice.h:101
DtInetUtils::DtInetAddrFamily myAddrFamily
Definition: vlInetTcpSocket.h:265
void * myIoService
Definition: vlInetTcpSocket.h:258
unsigned short DtU16
A 16 bit unsigned integer value.
Definition: vlMachineTypes.h:140
int send(int s, char *buf, int bufLen, int flags)
unsigned long DtU32
A 32 bit unsigned integer value.
Definition: vlMachineTypes.h:153
void * myTcpAcceptor
Definition: vlInetTcpSocket.h:260
The DtInetSocket class provides an address family independent stream socket.
Definition: vlInetTcpSocket.h:23
#define DtDefaultSockOpts
Marks the Socket as Writable.
Definition: vlInetSocket.h:90
void * myTcpSocket
Definition: vlInetTcpSocket.h:259
#define DT_DLL_VLUTIL
Definition: vlMachineTypes.h:109

Document ID: Generated on Tue Feb 2 21:02:17 EST 2021 from SVN revision 223668
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)