// @(#)root/base:$Id$
// Author: Fons Rademakers   16/12/96

/*************************************************************************
 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

#ifndef ROOT_TInetAddress
#define ROOT_TInetAddress


//////////////////////////////////////////////////////////////////////////
//                                                                      //
// TInetAddress                                                         //
//                                                                      //
// This class represents an Internet Protocol (IP) address.             //
// Objects of this class can not be created directly, but only via      //
// the TSystem GetHostByName(), GetSockName(), and GetPeerName()        //
// members and via members of the TServerSocket and TSocket classes.    //
//                                                                      //
//////////////////////////////////////////////////////////////////////////

#ifndef ROOT_TObject
#include "TObject.h"
#endif
#ifndef ROOT_TString
#include "TString.h"
#endif

#include <vector>
#ifdef R__GLOBALSTL
namespace std { using ::vector; }
#endif


class TInetAddress : public TObject {

friend class TSystem;
friend class TUnixSystem;
friend class TWinNTSystem;
friend class TUUID;
friend class TSocket;
friend class TUDPSocket;
friend class TServerSocket;
friend class TXSocket;   // special for BaBar

public:
   typedef std::vector<UInt_t>  AddressList_t;
   typedef std::vector<TString> AliasList_t;

private:
   TString       fHostname;    // fully qualified hostname
   Int_t         fFamily;      // address family
   Int_t         fPort;        // port through which we are connected
   AddressList_t fAddresses;   // list of all IP addresses in host byte order
   AliasList_t   fAliases;     // list of aliases

   TInetAddress(const char *host, UInt_t addr, Int_t family, Int_t port = -1);
   void AddAddress(UInt_t addr);
   void AddAlias(const char *alias);

public:
   TInetAddress();
   TInetAddress(const TInetAddress &adr);
   TInetAddress &operator=(const TInetAddress &rhs);
   virtual ~TInetAddress() { }

   UInt_t      GetAddress() const { return fAddresses[0]; }
   UChar_t    *GetAddressBytes() const;
   const char *GetHostAddress() const;
   const char *GetHostName() const { return (const char *) fHostname; }
   Int_t       GetFamily() const { return fFamily; }
   Int_t       GetPort() const { return fPort; }
   const AddressList_t &GetAddresses() const { return fAddresses; }
   const AliasList_t   &GetAliases() const { return fAliases; }
   Bool_t      IsValid() const { return fFamily == -1 ? kFALSE : kTRUE; }
   void        Print(Option_t *option="") const;

   static const char *GetHostAddress(UInt_t addr);

   ClassDef(TInetAddress,4)  //Represents an Internet Protocol (IP) address
};

#endif
 TInetAddress.h:1
 TInetAddress.h:2
 TInetAddress.h:3
 TInetAddress.h:4
 TInetAddress.h:5
 TInetAddress.h:6
 TInetAddress.h:7
 TInetAddress.h:8
 TInetAddress.h:9
 TInetAddress.h:10
 TInetAddress.h:11
 TInetAddress.h:12
 TInetAddress.h:13
 TInetAddress.h:14
 TInetAddress.h:15
 TInetAddress.h:16
 TInetAddress.h:17
 TInetAddress.h:18
 TInetAddress.h:19
 TInetAddress.h:20
 TInetAddress.h:21
 TInetAddress.h:22
 TInetAddress.h:23
 TInetAddress.h:24
 TInetAddress.h:25
 TInetAddress.h:26
 TInetAddress.h:27
 TInetAddress.h:28
 TInetAddress.h:29
 TInetAddress.h:30
 TInetAddress.h:31
 TInetAddress.h:32
 TInetAddress.h:33
 TInetAddress.h:34
 TInetAddress.h:35
 TInetAddress.h:36
 TInetAddress.h:37
 TInetAddress.h:38
 TInetAddress.h:39
 TInetAddress.h:40
 TInetAddress.h:41
 TInetAddress.h:42
 TInetAddress.h:43
 TInetAddress.h:44
 TInetAddress.h:45
 TInetAddress.h:46
 TInetAddress.h:47
 TInetAddress.h:48
 TInetAddress.h:49
 TInetAddress.h:50
 TInetAddress.h:51
 TInetAddress.h:52
 TInetAddress.h:53
 TInetAddress.h:54
 TInetAddress.h:55
 TInetAddress.h:56
 TInetAddress.h:57
 TInetAddress.h:58
 TInetAddress.h:59
 TInetAddress.h:60
 TInetAddress.h:61
 TInetAddress.h:62
 TInetAddress.h:63
 TInetAddress.h:64
 TInetAddress.h:65
 TInetAddress.h:66
 TInetAddress.h:67
 TInetAddress.h:68
 TInetAddress.h:69
 TInetAddress.h:70
 TInetAddress.h:71
 TInetAddress.h:72
 TInetAddress.h:73
 TInetAddress.h:74
 TInetAddress.h:75
 TInetAddress.h:76
 TInetAddress.h:77
 TInetAddress.h:78
 TInetAddress.h:79
 TInetAddress.h:80
 TInetAddress.h:81
 TInetAddress.h:82
 TInetAddress.h:83
 TInetAddress.h:84
 TInetAddress.h:85
 TInetAddress.h:86
 TInetAddress.h:87
 TInetAddress.h:88