8 [global::__DynamicallyInvokable]
11 internal const int IPv6AddressSize = 28;
13 internal const int IPv4AddressSize = 16;
17 internal byte[] m_Buffer;
19 private const int WriteableOffset = 2;
21 private const int MaxSize = 32;
23 private bool m_changed =
true;
29 [global::__DynamicallyInvokable]
32 [global::__DynamicallyInvokable]
41 [global::__DynamicallyInvokable]
44 [global::__DynamicallyInvokable]
55 [global::__DynamicallyInvokable]
56 public byte this[
int offset]
58 [global::__DynamicallyInvokable]
61 if (offset < 0 || offset >=
Size)
65 return m_Buffer[offset];
67 [global::__DynamicallyInvokable]
70 if (offset < 0 || offset >=
Size)
74 if (m_Buffer[offset] != value)
78 m_Buffer[offset] = value;
84 [global::__DynamicallyInvokable]
95 [global::__DynamicallyInvokable]
104 m_Buffer[0] = (
byte)family;
105 m_Buffer[1] = (byte)((
int)family >> 8);
119 long scopeId = ipAddress.
ScopeId;
120 m_Buffer[24] = (byte)scopeId;
121 m_Buffer[25] = (byte)(scopeId >> 8);
122 m_Buffer[26] = (byte)(scopeId >> 16);
123 m_Buffer[27] = (byte)(scopeId >> 24);
125 for (
int i = 0; i < addressBytes.Length; i++)
127 m_Buffer[8 + i] = addressBytes[i];
132 m_Buffer[4] = (byte)ipAddress.m_Address;
133 m_Buffer[5] = (
byte)(ipAddress.m_Address >> 8);
134 m_Buffer[6] = (byte)(ipAddress.m_Address >> 16);
135 m_Buffer[7] = (byte)(ipAddress.m_Address >> 24);
142 m_Buffer[2] = (byte)(port >> 8);
143 m_Buffer[3] = (byte)port;
146 internal IPAddress GetIPAddress()
150 byte[] array =
new byte[16];
151 for (
int i = 0; i < array.Length; i++)
153 array[i] = m_Buffer[i + 8];
155 long scopeid = (m_Buffer[27] << 24) + (m_Buffer[26] << 16) + (m_Buffer[25] << 8) + m_Buffer[24];
156 return new IPAddress(array, scopeid);
160 long newAddress = ((m_Buffer[4] & 0xFF) | ((m_Buffer[5] << 8) & 0xFF00) | ((m_Buffer[6] << 16) & 0xFF0000) | (m_Buffer[7] << 24)) & uint.MaxValue;
161 return new IPAddress(newAddress);
166 internal IPEndPoint GetIPEndPoint()
168 IPAddress iPAddress = GetIPAddress();
169 int port = ((m_Buffer[2] << 8) & 0xFF00) | m_Buffer[3];
170 return new IPEndPoint(iPAddress, port);
173 internal void CopyAddressSizeIntoBuffer()
175 m_Buffer[m_Buffer.Length - IntPtr.Size] = (byte)m_Size;
176 m_Buffer[m_Buffer.Length - IntPtr.Size + 1] = (byte)(m_Size >> 8);
177 m_Buffer[m_Buffer.Length - IntPtr.Size + 2] = (byte)(m_Size >> 16);
178 m_Buffer[m_Buffer.Length - IntPtr.Size + 3] = (byte)(m_Size >> 24);
181 internal int GetAddressSizeOffset()
183 return m_Buffer.Length - IntPtr.Size;
186 internal unsafe
void SetSize(IntPtr ptr)
188 m_Size = *(
int*)(
void*)ptr;
195 [global::__DynamicallyInvokable]
196 public override bool Equals(
object comparand)
199 if (socketAddress ==
null ||
Size != socketAddress.
Size)
203 for (
int i = 0; i <
Size; i++)
205 if (
this[i] != socketAddress[i])
215 [global::__DynamicallyInvokable]
224 for (i = 0; i < num; i += 4)
226 m_hash ^= (m_Buffer[i] | (m_Buffer[i + 1] << 8) | (m_Buffer[i + 2] << 16) | (m_Buffer[i + 3] << 24));
232 for (; i <
Size; i++)
234 num2 |= m_Buffer[i] << num3;
245 [global::__DynamicallyInvokable]
249 for (
int i = 2; i <
Size; i++)
253 stringBuilder.
Append(
",");
unsafe override string ToString()
Converts the value of this instance to a T:System.String.
The exception that is thrown when the value of an argument is outside the allowable range of values a...
The exception that is thrown when a socket error occurs.
AddressFamily AddressFamily
Gets the address family of the IP address.
SocketAddress(AddressFamily family, int size)
Creates a new instance of the T:System.Net.SocketAddress class using the specified address family and...
override string ToString()
Returns information about the socket address.
Provides an Internet Protocol (IP) address.
AddressFamily Family
Gets the T:System.Net.Sockets.AddressFamily enumerated value of the current T:System....
StringBuilder Append(char value, int repeatCount)
Appends a specified number of copies of the string representation of a Unicode character to this inst...
The exception that is thrown when an attempt is made to access an element of an array or collection w...
AddressFamily
Specifies the addressing scheme that an instance of the T:System.Net.Sockets.Socket class can use.
override bool Equals(object comparand)
Determines whether the specified Object is equal to the current Object.
A platform-specific type that is used to represent a pointer or a handle.
SocketAddress(AddressFamily family)
Creates a new instance of the T:System.Net.SocketAddress class for the given address family.
Stores serialized information from T:System.Net.EndPoint derived classes.
long ScopeId
Gets or sets the IPv6 address scope identifier.
Represents a mutable string of characters. This class cannot be inherited.To browse the ....
static int Size
Gets the size of this instance.
byte [] GetAddressBytes()
Provides a copy of the T:System.Net.IPAddress as an array of bytes.
Address for IP version 4.
SocketError
Defines error codes for the T:System.Net.Sockets.Socket class.
int Size
Gets the underlying buffer size of the T:System.Net.SocketAddress.
override int GetHashCode()
Serves as a hash function for a particular type, suitable for use in hashing algorithms and data stru...