2 // System.Net.SocketAddress.cs
5 // Miguel de Icaza (miguel@ximian.com)
6 // Dick Porter (dick@ximian.com)
8 // (C) Ximian, Inc. http://www.ximian.com
11 using System.Net.Sockets;
13 namespace System.Net {
15 public class SocketAddress {
18 public SocketAddress (AddressFamily family, int size)
21 throw new ArgumentOutOfRangeException("size is too small");
26 data[1]=(byte) ((int) family >> 8);
29 public SocketAddress (AddressFamily family)
34 //LAMESPEC: the MS doc about this class is wrong. The size is not stored in byte 1. Instead
35 // byte [0] and byte [1] hold the family (little endian).
36 public AddressFamily Family {
38 return (AddressFamily) (data [0] + (data [1] << 8));
48 public byte this [ int offset ] {
58 public override string ToString() {
59 string af=((AddressFamily)data[0]).ToString();
60 int size = data.Length;
61 string ret=af+":"+size+":{";
63 for(int i=2; i<size; i++) {
76 public override bool Equals (object obj)
78 if (obj is System.Net.SocketAddress &&
79 ((System.Net.SocketAddress) obj).data.Length == data.Length){
80 byte [] otherData = ((System.Net.SocketAddress) obj).data;
81 for (int i = 0; i < data.Length; i++)
82 if (otherData [i] != data [i])
91 public override int GetHashCode ()
95 for (int i = 0; i < data.Length; i++)