ROOT  6.06/09
Reference Guide
TInetAddress.h
Go to the documentation of this file.
1 // @(#)root/base:$Id$
2 // Author: Fons Rademakers 16/12/96
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #ifndef ROOT_TInetAddress
13 #define ROOT_TInetAddress
14 
15 
16 //////////////////////////////////////////////////////////////////////////
17 // //
18 // TInetAddress //
19 // //
20 // This class represents an Internet Protocol (IP) address. //
21 // Objects of this class can not be created directly, but only via //
22 // the TSystem GetHostByName(), GetSockName(), and GetPeerName() //
23 // members and via members of the TServerSocket and TSocket classes. //
24 // //
25 //////////////////////////////////////////////////////////////////////////
26 
27 #ifndef ROOT_TObject
28 #include "TObject.h"
29 #endif
30 #ifndef ROOT_TString
31 #include "TString.h"
32 #endif
33 
34 #include <vector>
35 #ifdef R__GLOBALSTL
36 namespace std { using ::vector; }
37 #endif
38 
39 
40 class TInetAddress : public TObject {
41 
42 friend class TSystem;
43 friend class TUnixSystem;
44 friend class TWinNTSystem;
45 friend class TUUID;
46 friend class TSocket;
47 friend class TUDPSocket;
48 friend class TServerSocket;
49 friend class TXSocket; // special for BaBar
50 
51 public:
52  typedef std::vector<UInt_t> AddressList_t;
53  typedef std::vector<TString> AliasList_t;
54 
55 private:
56  TString fHostname; // fully qualified hostname
57  Int_t fFamily; // address family
58  Int_t fPort; // port through which we are connected
59  AddressList_t fAddresses; // list of all IP addresses in host byte order
60  AliasList_t fAliases; // list of aliases
61 
62  TInetAddress(const char *host, UInt_t addr, Int_t family, Int_t port = -1);
63  void AddAddress(UInt_t addr);
64  void AddAlias(const char *alias);
65 
66 public:
67  TInetAddress();
68  TInetAddress(const TInetAddress &adr);
69  TInetAddress &operator=(const TInetAddress &rhs);
70  virtual ~TInetAddress() { }
71 
72  UInt_t GetAddress() const { return fAddresses[0]; }
73  UChar_t *GetAddressBytes() const;
74  const char *GetHostAddress() const;
75  const char *GetHostName() const { return (const char *) fHostname; }
76  Int_t GetFamily() const { return fFamily; }
77  Int_t GetPort() const { return fPort; }
78  const AddressList_t &GetAddresses() const { return fAddresses; }
79  const AliasList_t &GetAliases() const { return fAliases; }
80  Bool_t IsValid() const { return fFamily == -1 ? kFALSE : kTRUE; }
81  void Print(Option_t *option="") const;
82 
83  static const char *GetHostAddress(UInt_t addr);
84 
85  ClassDef(TInetAddress,4) //Represents an Internet Protocol (IP) address
86 };
87 
88 #endif
const char * GetHostName() const
Definition: TInetAddress.h:75
const char Option_t
Definition: RtypesCore.h:62
Int_t GetPort() const
Definition: TInetAddress.h:77
This class represents an Internet Protocol (IP) address.
Definition: TInetAddress.h:40
Basic string class.
Definition: TString.h:137
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
const Bool_t kFALSE
Definition: Rtypes.h:92
const AliasList_t & GetAliases() const
Definition: TInetAddress.h:79
STL namespace.
const AddressList_t & GetAddresses() const
Definition: TInetAddress.h:78
This class defines a UUID (Universally Unique IDentifier), also known as GUIDs (Globally Unique IDent...
Definition: TUUID.h:44
#define ClassDef(name, id)
Definition: Rtypes.h:254
std::vector< UInt_t > AddressList_t
Definition: TInetAddress.h:52
Bool_t IsValid() const
Definition: TInetAddress.h:80
std::vector< TString > AliasList_t
Definition: TInetAddress.h:53
TString fHostname
Definition: TInetAddress.h:56
UInt_t GetAddress() const
Definition: TInetAddress.h:72
UChar_t * GetAddressBytes() const
Returns the raw IP address in host byte order.
unsigned int UInt_t
Definition: RtypesCore.h:42
AliasList_t fAliases
Definition: TInetAddress.h:60
void AddAlias(const char *alias)
Add alias to list of aliases.
virtual ~TInetAddress()
Definition: TInetAddress.h:70
void AddAddress(UInt_t addr)
Add alternative address to list of addresses.
TInetAddress & operator=(const TInetAddress &rhs)
TInetAddress assignment operator.
Int_t GetFamily() const
Definition: TInetAddress.h:76
void Print(Option_t *option="") const
Print internet address as string.
Mother of all ROOT objects.
Definition: TObject.h:58
unsigned char UChar_t
Definition: RtypesCore.h:34
AddressList_t fAddresses
Definition: TInetAddress.h:59
Abstract base class defining a generic interface to the underlying Operating System.
Definition: TSystem.h:258
const Bool_t kTRUE
Definition: Rtypes.h:91
const char * GetHostAddress() const
Returns the IP address string "%d.%d.%d.%d".