IPHostEntry.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. // System.Net.IPHostEntry.cs
  2. //
  3. // Author: Mads Pultz ([email protected])
  4. //
  5. // (C) Mads Pultz, 2001
  6. using System;
  7. namespace System.Net {
  8. public class IPHostEntry {
  9. private IPAddress[] addressList;
  10. private String[] aliases;
  11. private String hostName;
  12. public IPHostEntry() {
  13. hostName = "localhost";
  14. addressList = new IPAddress[1];
  15. addressList[0] = IPAddress.Loopback;
  16. aliases = new String[0];
  17. }
  18. public IPAddress[] AddressList {
  19. get { return addressList; }
  20. set { addressList = value; }
  21. }
  22. public string[] Aliases {
  23. get { return aliases; }
  24. set { aliases = value; }
  25. }
  26. public string HostName {
  27. get { return hostName; }
  28. set { hostName = value; }
  29. }
  30. /* According to the .NET Framework SDK Documentation (beta 2) the following
  31. methods from Object are not overrided. I implemented them before realizing
  32. this but I leave the implementation here if needed in the future.
  33. public override string ToString() {
  34. string res = hostName;
  35. if (addressList != null && addressList.Length > 0)
  36. res += " [" + addressList[0] + "]";
  37. return res;
  38. }
  39. public override bool Equals(object obj) {
  40. if (obj is IPHostEntry) {
  41. IPHostEntry h = (IPHostEntry)obj;
  42. return hostName.Equals(h.HostName) && aliases.Equals(h.Aliases) &&
  43. addressList.Equals(h.AddressList);
  44. }
  45. else
  46. return false;
  47. }
  48. public override int GetHashCode() {
  49. return hostName.GetHashCode();
  50. }
  51. protected new object MemberwiseClone() {
  52. IPHostEntry res = new IPHostEntry();
  53. res.AddressList = new IPAddress[addressList.Length];
  54. Array.Copy(addressList, res.AddressList, addressList.Length);
  55. res.Aliases = new String[aliases.Length];
  56. Array.Copy(aliases, res.Aliases, aliases.Length);
  57. res.HostName = hostName;
  58. return res;
  59. }
  60. */
  61. }
  62. }