1 // System.Net.IPHostEntry.cs
3 // Author: Mads Pultz (mpultz@diku.dk)
5 // (C) Mads Pultz, 2001
11 public class IPHostEntry {
12 private IPAddress[] addressList;
13 private String[] aliases;
14 private String hostName;
16 public IPHostEntry() {
17 hostName = "localhost";
18 addressList = new IPAddress[1];
19 addressList[0] = IPAddress.Loopback;
20 aliases = new String[0];
23 public IPAddress[] AddressList {
24 get { return addressList; }
25 set { addressList = value; }
28 public string[] Aliases {
29 get { return aliases; }
30 set { aliases = value; }
33 public string HostName {
34 get { return hostName; }
35 set { hostName = value; }
38 /* According to the .NET Framework SDK Documentation (beta 2) the following
39 methods from Object are not overrided. I implemented them before realizing
40 this but I leave the implementation here if needed in the future.
42 public override string ToString() {
43 string res = hostName;
44 if (addressList != null && addressList.Length > 0)
45 res += " [" + addressList[0] + "]";
49 public override bool Equals(object obj) {
50 if (obj is IPHostEntry) {
51 IPHostEntry h = (IPHostEntry)obj;
52 return hostName.Equals(h.HostName) && aliases.Equals(h.Aliases) &&
53 addressList.Equals(h.AddressList);
59 public override int GetHashCode() {
60 return hostName.GetHashCode();
63 protected new object MemberwiseClone() {
64 IPHostEntry res = new IPHostEntry();
65 res.AddressList = new IPAddress[addressList.Length];
66 Array.Copy(addressList, res.AddressList, addressList.Length);
67 res.Aliases = new String[aliases.Length];
68 Array.Copy(aliases, res.Aliases, aliases.Length);
69 res.HostName = hostName;