VR-Link API Documentation for HLA 1.3
vlTcpSocketMgr.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: vlTcpSocketMgr.h,v $ $Revision: 1.2.6.1 $ $State: Exp $
00007 *********************************************************************/
00008 #ifndef vlTcpSocketMgr_H_
00009 #define vlTcpSocketMgr_H_
00010 
00014 
00015 #include <vlutil/vlMachineTypes.h>    
00016 #include <vlutil/vlNetTypes.h>
00017 #include <vlutil/vlUtil.h>
00018 #include "vlTcpSocket.h"
00019 
00020 #ifdef DtUSE_UTILITIES_NAMESPACE
00021 namespace DtUSE_UTILITIES_NAMESPACE
00022 {
00023 #endif
00024 
00025 
00027 typedef void (*DtSocketAdditionCallback)(DtTcpSocket* sock, void* usr);
00029 typedef DtSocketAdditionCallback DtSocketRemovalCallback;
00030 class DtTcpSocketMgr;
00033 typedef DtSocket* (*DtSocketCreationCallback)(void* creator, DtTcpSocketMgr * mgr);
00034 
00035 
00037 class DT_DLL_NETCOMPAT DtTcpSocketMgr
00038 {
00039 public:
00040    
00042    DtTcpSocketMgr(int port=DtDEFAULT_PORT);
00048    DtTcpSocketMgr(DtSocketCreationCallback cb, void *socketCreator, int port=DtDEFAULT_PORT);
00049 
00051    virtual ~DtTcpSocketMgr();
00052 
00055    virtual void processConnections();
00056 
00058    virtual int isOk() const;
00059 
00062    virtual int addrInUse() const;
00063 
00068    virtual DtIpv4Addr currentClientAddr() const;
00069 
00074    virtual int currentClientPort() const;
00075 
00080    virtual int currentSockFd() const;
00081 
00083    virtual const DtList* socketList();
00084 
00087    void removeAndDelete(DtTcpSocket* sock);
00088 
00092    void setNoDelay(bool onOff);
00093 
00096    virtual void addSocketAdditionCallback(
00097       DtSocketAdditionCallback cb, void* usr);
00098    virtual void removeSocketAdditionCallback(
00099       DtSocketAdditionCallback cb, void* usr);
00100    
00103    virtual void addSocketRemovalCallback(
00104       DtSocketRemovalCallback cb, void* usr);
00105    virtual void removeSocketRemovalCallback(
00106       DtSocketRemovalCallback cb, void* usr);
00107 
00111    virtual int sizeOffset();
00112    virtual int sizeLength();
00113    virtual void setSizeOffset(int offset);
00114    virtual void setSizeLength(int length);
00115 
00118    virtual void setPacketBundling( unsigned int maxBundleSize );
00119 
00120 protected:
00121    
00123    virtual void emptyCallbackLists();
00124 
00126    DtTcpSocketMgr(const DtTcpSocketMgr&);
00127 
00129    DtTcpSocketMgr& operator=(const DtTcpSocketMgr &);
00130 
00131 protected:
00132 
00133    int serverSockfd;
00134    int mySizeOffset;
00135    int mySizeLength;
00137 
00139    int myCurrentSockFd;
00141    DtIpv4Addr myServAddr;
00142    DtIpv4Addr myCliAddr;
00144    int myCliPort;
00146    DtList* mySockList;
00147    int myOk;
00148    int myAddrInUse;
00149    bool myNoDelay;
00150    unsigned int myMaxBundleSize;
00151 
00153    DtSocketCreationCallback mySocketCreationCb;
00155    void * mySocketCreator;
00156 
00157    
00159    DtList myAdditionCallbacks;
00160    DtList myRemovalCallbacks;
00161 };
00162 
00163 inline int DtTcpSocketMgr::isOk() const
00164 {
00165    return myOk; 
00166 }
00167 
00168 inline int DtTcpSocketMgr::sizeLength()
00169 {
00170    return mySizeLength;
00171 }
00172 
00173 inline int DtTcpSocketMgr::sizeOffset()
00174 {
00175    return mySizeOffset;
00176 }
00177 
00178 #ifdef DtUSE_UTILITIES_NAMESPACE
00179 } 
00180 #endif
00181 
00182 
00183 #endif

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)