⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 netinterface.hh

📁 流媒体传输协议的实现代码,非常有用.可以支持rtsp mms等流媒体传输协议
💻 HH
字号:
/**********This library is free software; you can redistribute it and/or modify it underthe terms of the GNU Lesser General Public License as published by theFree Software Foundation; either version 2.1 of the License, or (at youroption) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)This library is distributed in the hope that it will be useful, but WITHOUTANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESSFOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License formore details.You should have received a copy of the GNU Lesser General Public Licensealong with this library; if not, write to the Free Software Foundation, Inc.,59 Temple Place, Suite 330, Boston, MA  02111-1307  USA**********/// "mTunnel" multicast access service// Copyright (c) 1996-2001 Live Networks, Inc.  All rights reserved.// Network Interfaces// C++ header#ifndef _NET_INTERFACE_HH#define _NET_INTERFACE_HH#ifndef _NET_ADDRESS_HH#include "NetAddress.hh"#endifclass NetInterface {public:  virtual ~NetInterface();    static UsageEnvironment* DefaultUsageEnvironment;      // if non-NULL, used for each new interfaces  protected:  NetInterface(); // virtual base class};class DirectedNetInterface: public NetInterface {public:  virtual ~DirectedNetInterface();    virtual Boolean write(unsigned char* data, unsigned numBytes) = 0;    virtual Boolean SourceAddrOKForRelaying(UsageEnvironment& env,					  unsigned addr) = 0;  protected:  DirectedNetInterface(); // virtual base class};class DirectedNetInterfaceSet {public:  DirectedNetInterfaceSet();  virtual ~DirectedNetInterfaceSet();    DirectedNetInterface* Add(DirectedNetInterface const* interf);      // Returns the old value if different, otherwise 0  Boolean Remove(DirectedNetInterface const* interf);    Boolean IsEmpty() { return fTable->IsEmpty(); }    // Used to iterate through the interfaces in the set  class Iterator {  public:    Iterator(DirectedNetInterfaceSet& interfaces);    virtual ~Iterator();        DirectedNetInterface* next(); // NULL iff none      private:    HashTable::Iterator* fIter;  };  private:  friend class Iterator;  HashTable* fTable;};class Socket: public NetInterface {public:  virtual ~Socket();    virtual Boolean handleRead(unsigned char* buffer, unsigned bufferMaxSize,			     unsigned& bytesRead,			     struct sockaddr_in& fromAddress) = 0;      // Returns False on error; resultData == NULL if data ignored    int socketNum() const { return fSocketNum; }    Port port() const {    return fPort;  }    UsageEnvironment& env() const { return fEnv; }    static int DebugLevel;  protected:  Socket(UsageEnvironment& env, Port port,	 Boolean setLoopback = True); // virtual base class  private:  int fSocketNum;  UsageEnvironment& fEnv;  Port fPort;};UsageEnvironment& operator<<(UsageEnvironment& s, const Socket& sock);// A data structure for looking up a Socket by port:class SocketLookupTable {public:  virtual ~SocketLookupTable();    Socket* Fetch(UsageEnvironment& env, Port port, Boolean& isNew);  // Creates a new Socket if none already exists  Boolean Remove(Socket const* sock);  protected:  SocketLookupTable(); // abstract base class  virtual Socket* CreateNew(UsageEnvironment& env, Port port) = 0;  private:  HashTable* fTable;};// A data structure for counting traffic:class NetInterfaceTrafficStats {public:  NetInterfaceTrafficStats();    void countPacket(unsigned packetSize);    float totNumPackets() const {return fTotNumPackets;}  float totNumBytes() const {return fTotNumBytes;}    Boolean haveSeenTraffic() const;  private:  float fTotNumPackets;  float fTotNumBytes;};#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -