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-2026 MAK Technologies, Inc
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 = nullptr,
46  DtU32 flags = DtSockOptNoDelay, bool immediateOpen = true, DtInetProtocol protocolToUse = DtInetProtocol_TCP );
47 
75  DtInetTcpSocket( const DtInetEndpoint& dest, DtU16 localPort = 0,
76  DtInetDevice* hostIf = nullptr, DtU32 flags = DtDefaultSockOpts,
77  bool immediateOpen = true );
78 
80  virtual ~DtInetTcpSocket();
81 
88  virtual bool setDestination( const DtInetEndpoint& addr ) override;
89 
94  virtual bool openSocket() override;
95 
99  virtual bool closeSocket() override;
100 
108  virtual bool bindToDevice( const DtInetDevice* hostIf = nullptr ) override;
109 
111  virtual bool listenForConnections();
112 
122  virtual bool acceptConnection( DtInetTcpSocket* peer,
123  DtU32 flags = DtDefaultSockOpts);
124 
131  virtual bool connectToDestination() override;
132 
140  virtual int send( caddr_t packet, size_t size, DtU32 flags = 0 ) override;
141  virtual int sendTo( caddr_t packet, size_t size,
142  DtInetEndpoint& dest, DtU32 flags = 0 ) override;
143 
144  virtual int sendChain( DtInetBufferChain& packets, DtU32 flags = 0 ) override;
145  virtual int sendChainTo( DtInetBufferChain& packets,
146  DtInetEndpoint& dest, DtU32 flags = 0 ) override;
148 
157 
162  virtual DtInetSockRcvStatus recv( caddr_t buff, size_t buffSize,
163  DtU32 flags = 0 ) override;
168  virtual DtInetSockRcvStatus recvToChain( DtInetBufferChain& packets,
169  DtU32 flags = 0 ) override;
174  virtual DtInetSockRcvStatus recvFrom( caddr_t buff, size_t buffSize,
175  DtInetEndpoint& src,
176  DtU32 flags = 0 ) override ;
177  virtual DtInetSockRcvStatus recvToChainFrom( DtInetBufferChain& packets,
178  DtInetEndpoint& src,
179  DtU32 flags = 0 ) override;
181 
186  virtual bool setSocket( const DtInetEndpoint& dest, DtU16 localPort = 0,
187  DtInetDevice* hostIf = NULL, DtU32 flags = DtDefaultSockOpts ) override;
188 
195  virtual bool isOk() override;
196 
198  virtual unsigned descriptor() const override;
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:
229 
232  virtual bool initAcceptedConnection( const DtInetEndpoint& localEndpoint, DtU32 flags = DtDefaultSockOpts );
233 
237  virtual bool openAcceptedConnection( const DtInetEndpoint& peer );
238 
240  virtual bool openSocket(DtInetProtocol protocolToUse);
241 
243  virtual void* tcpSocket();
244  virtual void* tcpServerSocket();
245 
247  bool isServerSock() const;
248 
249 private:
251  DtInetTcpSocket( const DtInetTcpSocket& orig );
252 
254  DtInetTcpSocket& operator=(const DtInetTcpSocket& orig);
255 
257  friend class DtInetTcpSockPimpl;
258  DtInetTcpSockPimpl* myAsyncPimpl;
259 
260 protected:
261  void* myIoService;
262  void* myTcpSocket;
263  void* myTcpAcceptor; // server sockets only
264 
265  // This member should only be used by 'server' sockets. All other sockets
266  // should set this to DtInetUtils::DtInetAddrFamily_INVALID to differentiate
267  // server and client sockets.
269 };
270 // end of class DtInetTcpSocket
271 
272 #ifdef DtUSE_UTILITIES_NAMESPACE
273 }
274 #endif
275 
276 
277 
278 
This file contains the declaration of the DtInetSocket base class.
Definition: vlInetAddrUtils.h:58
Definition: vlInetEndpoint.h:25
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:258
DtInetAddrFamily
Definition: vlInetAddrUtils.h:55
The DtInetEndpoint class provides a protocol independant, address family independent mechanism to rep...
Definition: vlInetEndpoint.h:34
Definition: vlInetDevice.h:101
DtInetUtils::DtInetAddrFamily myAddrFamily
Definition: vlInetTcpSocket.h:268
void * myIoService
Definition: vlInetTcpSocket.h:261
DtInetProtocol
Specifies the protocol used by the endpoint.
Definition: vlInetEndpoint.h:22
unsigned short DtU16
A 16 bit unsigned integer value.
Definition: vlMachineTypes.h:152
int send(int s, char *buf, int bufLen, int flags)
unsigned long DtU32
A 32 bit unsigned integer value.
Definition: vlMachineTypes.h:165
void * myTcpAcceptor
Definition: vlInetTcpSocket.h:263
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:262
#define DT_DLL_VLUTIL
Definition: vlMachineTypes.h:121

Document ID: Generated on Mon Sep 28 00:09:32 EDT 2026 from SVN revision 295353
Copyright © 1992-2025 MAK Technologies. All Rights Reserved (www.mak.com)