📄 conn.h
字号:
UINT16 port) = 0; virtual ULONG32 get_addr (void) = 0; virtual UINT16 get_local_port (void) = 0; virtual void set_callback (HXAsyncNetCallback* pCallback) {mCallBack = pCallback;}; virtual HXAsyncNetCallback* get_callback() {return mCallBack;};/* connection_open() returns 1 if the socket is open 0 is it is closed */ virtual UINT16 connection_open (void) {return mConnectionOpen;}; virtual UINT16 connection_really_open (void) {return mConnectionOpen;};/* get_sock() returns the socket number or -1 if the socket is invalid */ virtual int get_sock (void) {return mSock;}; virtual void set_sock ( int theSock ) { mSock = theSock; }; virtual BOOL set_receive_buf_size(int DesiredSize) {return FALSE;};/* join_multicast_group() has this socket join a multicast group */ virtual HX_RESULT join_multicast_group (ULONG32 addr, ULONG32 if_addr = HX_INADDR_ANY) = 0; virtual HX_RESULT leave_multicast_group (ULONG32 addr, ULONG32 if_addr = HX_INADDR_ANY) = 0; virtual HX_RESULT set_multicast() {return HXR_NOTIMPL;}; virtual HX_RESULT set_multicast_ttl(unsigned char ttl) {return HXR_NOTIMPL;};/* SetSockOpt */ virtual HX_RESULT set_broadcast (BOOL enable) =0; virtual HX_RESULT reuse_addr(BOOL enable) {return HXR_NOTIMPL;}; virtual HX_RESULT reuse_port(BOOL enable) {return HXR_NOTIMPL;}; virtual HX_RESULT set_multicast_if(UINT32 ulInterface) = 0; virtual HX_RESULT set_send_size(UINT32 send_size) {return HXR_NOTIMPL;}; // IHXNetworkInterfaceEnumerator support */ static HX_RESULT EnumerateInterfaces (REF(UINT32*) pulInterfaces, REF(UINT32) ulNumInterfaces); static HX_RESULT get_host_name(char *name, int namelen); static HX_RESULT get_host_by_name(char *name, REF(struct hostent*) pHostent); virtual void SetUserThread(HXThread* pThread) {m_pUserThread = pThread;}; virtual HXThread* GetUserThread(void) {return m_pUserThread;};/* get_first_connection_position returns the position of the first connection in the list of connections; if the list is empty the return value is NULL */ static POSITION get_first_connection_position ();/* get_next_connection returns the conn object at POSITION and increments POSITION to point to the next */ static void get_next_connection (POSITION& nextPos, conn *& rpConn); static void set_maxbandwidth (UINT32 ulBandwidth); // TCP max. bandwidth management static UINT32 bytes_to_preparetcpread(conn* pConn); static void bytes_to_actualtcpread(conn* pConn, UINT32 ulBytesRead); UINT32 m_ulLastStarvingTime; static UINT32 m_ulMaxBandwidth; inline void SetAsyncDNSPref(BOOL bNoAsyncDNS) { m_bNoAsyncDNS = bNoAsyncDNS; } inline BOOL GetAsyncDNSPref(void) const { return m_bNoAsyncDNS; } static inline void SetNetworkThreadingPref(BOOL bNetworkThreading) { m_bNetworkThreading = bNetworkThreading; } static inline BOOL GetNetworkThreadingPref(void) { return m_bNetworkThreading; } static inline void SetThreadedDNSPref(BOOL bThreadedDNS ) { m_bThreadedDNS = bThreadedDNS; } static inline BOOL GetThreadedDNSPref(void) { return m_bThreadedDNS; } /* * WinSock Recvfrom() Now Returns WSAECONNRESET Instead of Blocking or Timing Out (Q263823) * workaround - only for win UDP */ virtual void IgnoreWSAECONNRESET(BOOL b) {} /* * to run the networkthreadmainloop from select instead of the timer * implement this function in your platform specific connection class * the parameters are the 3 fdset structures and timeval used in select */#if defined(HELIX_FEATURE_NETWORK_USE_SELECT) virtual HX_RESULT WaitforSelect(void *,void *) = 0; virtual HX_RESULT CheckForConnection()=0;#endif /* HELIX_FEATURE_NETWORK_USE_SELECT */ protected:/* Constructor NOTE: use new_socket() to create an instance of this class */ conn (void);/* class destructor */ virtual ~conn (void); int mSock; HX_RESULT mLastError; // last error to occur on this socket UINT16 mConnectionOpen; HXAsyncNetCallback* mCallBack; static DNR_cache mCache[MAX_CACHE]; static UINT16 mCacheCount; // just for DNS for hostname... // is introduced for RTSP... ULONG32 mHostIPAddr; BOOL mHostIPValid; BOOL mDNSDone; HXThread* m_pUserThread; UCHAR* m_pUDPBuffer; protected:/* add_connection_to_list () is called by the factory method new_socket() to keep track of all the sockets in the system; it should only be accessible to the base class since that's where the factory method resides */ static void add_connection_to_list ( conn *pConn );/* remove_connection_from_list () is called in the base class destructor to remove objects from the list of connections. */ static void remove_connection_from_list ( conn *pConn ); static conn* actual_new_socket (UINT16 type); static CHXMapPtrToPtr* mConnectionList; static HXThread* m_pNetworkThread; // TCP max. bandwidth management static UINT32 m_ulTCPTotalBytesRead; static UINT32 m_ulTCPReadTimeStamp; static CHXSimpleList* m_pTCPStarvingList; //This member variable holds the pref for turning on/off Async //DNS. Async DNS, under un*x, uses a fork which screws up 'gdb'. //You can set NoAsyncDNS=1 in your prefs file to turn off the fork. BOOL m_bNoAsyncDNS; static BOOL m_bNetworkThreading; static BOOL m_bThreadedDNS;};class DestructConnGlobals{public: DestructConnGlobals() {}; ~DestructConnGlobals() {conn::DestructGlobals();};};#if defined(HELIX_FEATURE_SECURECONN)class secureconn : public conn{private: LONG32 m_lRefCount; conn* m_pActualConn; LONG32 m_FakeFD; static LONG32 zm_Count; IHXSSL* m_pHXSSL; public: secureconn(IHXSSL* pHXSSL); virtual ~secureconn(); virtual ULONG32 AddRef(void); virtual ULONG32 Release(void); virtual HX_RESULT connect(const char* host, UINT16 port, UINT16 blocking=0, ULONG32 ulPlatform=0); virtual HX_RESULT read(void* buf, UINT16* size); virtual HX_RESULT write(void* buf, UINT16* size); virtual HX_RESULT blocking(void); virtual HX_RESULT nonblocking(void); virtual HX_RESULT readfrom (REF(IHXBuffer*) pBuffer, REF(UINT32) ulAddress, REF(UINT16) ulPort); virtual HX_RESULT writeto (void *buf, UINT16 *len, ULONG32 addr, UINT16 port); virtual ULONG32 get_addr (void); virtual UINT16 get_local_port (void); virtual HX_RESULT dns_find_ip_addr (const char * host, UINT16 blocking=0); virtual BOOL dns_ip_addr_found(BOOL * valid, ULONG32 *addr); virtual void done(void); virtual HX_RESULT init (UINT32 local_addr, UINT16 port, UINT16 blocking=0); virtual HX_RESULT listen (ULONG32 ulLocalAddr, UINT16 port, UINT16 backlog, UINT16 blocking, ULONG32 ulPlatform); virtual HX_RESULT join_multicast_group (ULONG32 addr, ULONG32 if_addr = HX_INADDR_ANY); virtual HX_RESULT leave_multicast_group (ULONG32 addr, ULONG32 if_addr = HX_INADDR_ANY); virtual HX_RESULT set_broadcast (BOOL enable); virtual HX_RESULT set_multicast_if(UINT32 ulInterface); // all of these functions need to be implemented so I can // call through to the final implemenations' code. virtual HX_RESULT last_error (void);#if defined (_WINDOWS) || defined (_WIN32)// virtual HX_RESULT SetWindowHandle(ULONG32 handle) {return HXR_OK;};#elif defined (_MACINTOSH) virtual HX_RESULT GetEndpoint(REF(void*) pRef); virtual HX_RESULT SetupEndpoint(BOOL bWait);#endif virtual void set_callback (HXAsyncNetCallback* pCallback); virtual UINT16 connection_open (void); virtual int get_sock (void); virtual void set_sock ( int theSock ); virtual BOOL set_receive_buf_size(int DesiredSize); virtual HX_RESULT reuse_addr(BOOL enable); virtual HX_RESULT reuse_port(BOOL enable);#if defined(HELIX_FEATURE_NETWORK_USE_SELECT) HX_RESULT WaitforSelect(void *,void *) {return HXR_FAIL;}; virtual HX_RESULT CheckForConnection(){return HXR_FAIL;};#endif // HELIX_FEATURE_NETWORK_USE_SELECT};class secureconnhelper{public:static CHXMapPtrToPtr zm_ConnMap;static conn* GetConn(LONG32 fakeFD);static void SetConn(LONG32 fakeFD, conn* pConn);// callbacks from rnsslstatic long readCallback(LONG32 fakeFD, void* buff, LONG32 len);static long writeCallback(LONG32 fakeFD, void* buff, LONG32 len);static void closeCallback(LONG32 fakeFD);};#endif /* HELIX_FEATURE_SECURECONN */ #endif // _conn
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -