Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:12:10

0001 // @(#)root/base:$Id$
0002 // Author: Fons Rademakers   16/12/96
0003 
0004 /*************************************************************************
0005  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
0006  * All rights reserved.                                                  *
0007  *                                                                       *
0008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
0009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
0010  *************************************************************************/
0011 
0012 #ifndef ROOT_TInetAddress
0013 #define ROOT_TInetAddress
0014 
0015 
0016 //////////////////////////////////////////////////////////////////////////
0017 //                                                                      //
0018 // TInetAddress                                                         //
0019 //                                                                      //
0020 // This class represents an Internet Protocol (IP) address.             //
0021 // Objects of this class can not be created directly, but only via      //
0022 // the TSystem GetHostByName(), GetSockName(), and GetPeerName()        //
0023 // members and via members of the TServerSocket and TSocket classes.    //
0024 //                                                                      //
0025 //////////////////////////////////////////////////////////////////////////
0026 
0027 #include "TObject.h"
0028 #include "TString.h"
0029 
0030 #include <vector>
0031 #ifdef R__GLOBALSTL
0032 namespace std { using ::vector; }
0033 #endif
0034 
0035 
0036 class TInetAddress : public TObject {
0037 
0038 friend class TSystem;
0039 friend class TUnixSystem;
0040 friend class TWinNTSystem;
0041 friend class TUUID;
0042 friend class TSocket;
0043 friend class TUDPSocket;
0044 friend class TServerSocket;
0045 friend class TXSocket;   // special for BaBar
0046 
0047 public:
0048    typedef std::vector<UInt_t>  AddressList_t;
0049    typedef std::vector<TString> AliasList_t;
0050 
0051 private:
0052    TString       fHostname;    // fully qualified hostname
0053    Int_t         fFamily;      // address family
0054    Int_t         fPort;        // port through which we are connected
0055    AddressList_t fAddresses;   // list of all IP addresses in host byte order
0056    AliasList_t   fAliases;     // list of aliases
0057 
0058    TInetAddress(const char *host, UInt_t addr, Int_t family, Int_t port = -1);
0059    void AddAddress(UInt_t addr);
0060    void AddAlias(const char *alias);
0061 
0062 public:
0063    TInetAddress();
0064    TInetAddress(const TInetAddress &adr);
0065    TInetAddress &operator=(const TInetAddress &rhs);
0066    virtual ~TInetAddress() { }
0067 
0068    UInt_t      GetAddress() const { return fAddresses[0]; }
0069    UChar_t    *GetAddressBytes() const;
0070    const char *GetHostAddress() const;
0071    const char *GetHostName() const { return (const char *) fHostname; }
0072    Int_t       GetFamily() const { return fFamily; }
0073    Int_t       GetPort() const { return fPort; }
0074    const AddressList_t &GetAddresses() const { return fAddresses; }
0075    const AliasList_t   &GetAliases() const { return fAliases; }
0076    Bool_t      IsValid() const { return fFamily == -1 ? kFALSE : kTRUE; }
0077    void        Print(Option_t *option="") const override;
0078 
0079    static const char *GetHostAddress(UInt_t addr);
0080 
0081    ClassDefOverride(TInetAddress,4)  //Represents an Internet Protocol (IP) address
0082 };
0083 
0084 #endif