IPHostEntry.cs 2.7 KB

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