1 // System.Net.IPHostEntry.cs
3 // Author: Mads Pultz (mpultz@diku.dk)
5 // (C) Mads Pultz, 2001
8 // Permission is hereby granted, free of charge, to any person obtaining
9 // a copy of this software and associated documentation files (the
10 // "Software"), to deal in the Software without restriction, including
11 // without limitation the rights to use, copy, modify, merge, publish,
12 // distribute, sublicense, and/or sell copies of the Software, and to
13 // permit persons to whom the Software is furnished to do so, subject to
14 // the following conditions:
16 // The above copyright notice and this permission notice shall be
17 // included in all copies or substantial portions of the Software.
19 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
22 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
23 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
24 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
25 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30 namespace System.Net {
32 public class IPHostEntry {
33 private IPAddress[] addressList;
34 private String[] aliases;
35 private String hostName;
37 public IPHostEntry() {
40 public IPAddress[] AddressList {
41 get { return addressList; }
42 set { addressList = value; }
45 public string[] Aliases {
46 get { return aliases; }
47 set { aliases = value; }
50 public string HostName {
51 get { return hostName; }
52 set { hostName = value; }
55 /* According to the .NET Framework SDK Documentation (beta 2) the following
56 methods from Object are not overrided. I implemented them before realizing
57 this but I leave the implementation here if needed in the future.
59 public override string ToString() {
60 string res = hostName;
61 if (addressList != null && addressList.Length > 0)
62 res += " [" + addressList[0] + "]";
66 public override bool Equals(object obj) {
67 if (obj is IPHostEntry) {
68 IPHostEntry h = (IPHostEntry)obj;
69 return hostName.Equals(h.HostName) && aliases.Equals(h.Aliases) &&
70 addressList.Equals(h.AddressList);
76 public override int GetHashCode() {
77 return hostName.GetHashCode();
80 protected new object MemberwiseClone() {
81 IPHostEntry res = new IPHostEntry();
82 res.AddressList = new IPAddress[addressList.Length];
83 Array.Copy(addressList, res.AddressList, addressList.Length);
84 res.Aliases = new String[aliases.Length];
85 Array.Copy(aliases, res.Aliases, aliases.Length);
86 res.HostName = hostName;