VR-Link API Documentation for DIS
vlTcpSocket.h
Go to the documentation of this file.
00001 /*********************************************************************
00002 ** Copyright (c) 1992, 1997 MaK Technologies, Inc.
00003 ** All rights reserved.
00004 *********************************************************************/
00005 /*********************************************************************
00006 ** $RCSfile: vlTcpSocket.h,v $ $Revision: 1.2.6.5 $ $State: Exp $
00007 *********************************************************************/
00008 #ifndef vlTcpSocket_H_ 
00009 #define vlTcpSocket_H_
00010 
00011 
00012 
00013 
00014 #include "vlSocket.h"
00015 
00016 #ifdef DtUSE_UTILITIES_NAMESPACE
00017 namespace DtUSE_UTILITIES_NAMESPACE
00018 {
00019 #endif
00020 
00025 class DT_DLL_NETCOMPAT DtTcpMessage
00026 {
00027 public:
00028 
00029    DtTcpMessage( const char* buff, int size );
00030    DtTcpMessage( const char* buff, int offset, int size );
00031    ~DtTcpMessage();
00032 
00033    char* myBuff;
00034    int mySize;
00035 
00036 private:
00038    DtTcpMessage(const DtTcpMessage &);
00039 
00041    DtTcpMessage &operator=(const DtTcpMessage &);
00042 
00043 };
00044 
00047 class DT_DLL_NETCOMPAT DtTcpSocket : public DtSocket
00048 {
00049 public:
00050 
00052    DtTcpSocket(int socketfd, DtIpv4Addr addr, int clientPort = 0);
00053 
00055    DtTcpSocket(DtIpv4Addr addr, int port=DtDEFAULT_PORT, 
00056                int nonBlockingConnect=0);
00057 
00059    virtual ~DtTcpSocket();
00060 
00065    virtual int sendTo(caddr_t packet, size_t packetSize, 
00066                       DtIpv4Addr addr=DtUSE_DEFAULT_IP_ADDR);
00067 
00068    virtual int DtRecv(caddr_t *buffptr, int *status=NULL);
00069 
00070    virtual int DtRecv(caddr_t buff, size_t bufsize);
00071 
00074    virtual DtFlushStatus flush();
00075 
00079    virtual DtFlushStatus flush(long& byteCount);
00080 
00082    virtual void DtBecomeNonBlocking();
00083 
00085    virtual void DtBecomeBlocking();
00086 
00089    virtual bool isOk() const;
00090 
00094    virtual bool isConnectionEstablished();
00095 
00101    virtual bool testConnectionStatus();
00102 
00103    
00105    inline DtIpv4Addr getConnectionAddr() const;
00106    
00108    int sizeOffset() const { return mySizeOffset; }
00109    void setSizeOffset(int offset);
00110    
00112    int sizeLength() const { return mySizeLength; }
00113    void setSizeLength(int length);
00114 
00117    virtual void setNoDelay(bool onOff);
00118 
00120    virtual int peerPort() const;
00121 
00123    virtual int localPort() const;
00124 
00126    int maxForwarderQueue() const;
00127    void setMaxForwarderQueue( int maxForwarderQueue ); 
00128 
00129 public:
00130 
00133    static void setNoDelay(int sockfd, bool onOff);
00134 
00140    static void setPacketBufferSize(int size);
00141 
00145    std::pair<int, int> getQueueStatus() const;
00146 
00147 protected:
00148 
00153    int sendTo(caddr_t packet, size_t packetSize, bool reportMinSizePktFaults );
00154 
00155    int recvWithStatus(caddr_t *buffptr, int *status);
00156    int checkSize(int size, caddr_t *buffptr, int *status);
00157    bool expandPktBuffer( unsigned int sizeNeeded );
00158    int sendMinimumSizePkt( bool reportMinSizePktFaults );
00159 
00160 private:
00161 
00163    DtTcpSocket(const DtTcpSocket &);
00164 
00166    DtTcpSocket& operator=(const DtTcpSocket &);
00167    
00168 protected:
00169    
00170    char* myPktBuff;
00171    unsigned int myPktBuffSize;
00172    DtIpv4Addr myConnectAddr;
00173    int myPeerPort;
00174    int myLocalPort;
00175    bool myOk;
00176    int myNeedSize;
00177    int mySizeOffset;
00178    int mySizeLength;
00179    int myNumBytesToWaitFor;
00180    int myNumBytesReceived;
00181 
00184    DtList* myPktWaitList;
00185 
00187    int myMaxForwarderQueue;
00188 
00189 protected:
00190 
00191    static int thePktBuffSize;
00192 };
00193 
00194 inline DtIpv4Addr DtTcpSocket::getConnectionAddr() const
00195 {
00196    return myConnectAddr;
00197 }
00198 
00199 inline bool DtTcpSocket::isOk() const 
00200 { 
00201    return myOk; 
00202 }
00203 
00204 #ifdef DtUSE_UTILITIES_NAMESPACE
00205 } 
00206 #endif
00207 
00208 
00209 #endif
00210 
00211 
00212 
00213 
00214 
00215 
00216 
00217 
00218 

Document ID: Generated on Mon May 14 08:06:18 EDT 2012 from SVN revision 114750
Copyright © 2005-2012 VT MÄK Inc. All Rights Reserved (www.mak.com)