138 lines
5.3 KiB
C#
138 lines
5.3 KiB
C#
using System;
|
|
using System.Net.Sockets;
|
|
|
|
namespace System.Net
|
|
{
|
|
/// <summary>Stores serialized information from <see cref="T:System.Net.EndPoint" /> derived classes.</summary>
|
|
// Token: 0x02000257 RID: 599
|
|
public class SocketAddress
|
|
{
|
|
/// <summary>Creates a new instance of the <see cref="T:System.Net.SocketAddress" /> class using the specified address family and buffer size.</summary>
|
|
/// <param name="family">An <see cref="T:System.Net.Sockets.AddressFamily" /> enumerated value. </param>
|
|
/// <param name="size">The number of bytes to allocate for the underlying buffer. </param>
|
|
/// <exception cref="T:System.ArgumentOutOfRangeException">
|
|
/// <paramref name="size" /> is less than 2. These 2 bytes are needed to store <paramref name="family" />. </exception>
|
|
// Token: 0x06001571 RID: 5489 RVA: 0x00044D5C File Offset: 0x00042F5C
|
|
public SocketAddress(global::System.Net.Sockets.AddressFamily family, int size)
|
|
{
|
|
if (size < 2)
|
|
{
|
|
throw new ArgumentOutOfRangeException("size is too small");
|
|
}
|
|
this.data = new byte[size];
|
|
this.data[0] = (byte)family;
|
|
this.data[1] = (byte)(family >> 8);
|
|
}
|
|
|
|
/// <summary>Creates a new instance of the <see cref="T:System.Net.SocketAddress" /> class for the given address family.</summary>
|
|
/// <param name="family">An <see cref="T:System.Net.Sockets.AddressFamily" /> enumerated value. </param>
|
|
// Token: 0x06001572 RID: 5490 RVA: 0x00044DA4 File Offset: 0x00042FA4
|
|
public SocketAddress(global::System.Net.Sockets.AddressFamily family)
|
|
: this(family, 32)
|
|
{
|
|
}
|
|
|
|
/// <summary>Gets the <see cref="T:System.Net.Sockets.AddressFamily" /> enumerated value of the current <see cref="T:System.Net.SocketAddress" />.</summary>
|
|
/// <returns>One of the <see cref="T:System.Net.Sockets.AddressFamily" /> enumerated values.</returns>
|
|
// Token: 0x17000704 RID: 1796
|
|
// (get) Token: 0x06001573 RID: 5491 RVA: 0x00044DB0 File Offset: 0x00042FB0
|
|
public global::System.Net.Sockets.AddressFamily Family
|
|
{
|
|
get
|
|
{
|
|
return (global::System.Net.Sockets.AddressFamily)((int)this.data[0] + ((int)this.data[1] << 8));
|
|
}
|
|
}
|
|
|
|
/// <summary>Gets the underlying buffer size of the <see cref="T:System.Net.SocketAddress" />.</summary>
|
|
/// <returns>The underlying buffer size of the <see cref="T:System.Net.SocketAddress" />.</returns>
|
|
// Token: 0x17000705 RID: 1797
|
|
// (get) Token: 0x06001574 RID: 5492 RVA: 0x00044DC8 File Offset: 0x00042FC8
|
|
public int Size
|
|
{
|
|
get
|
|
{
|
|
return this.data.Length;
|
|
}
|
|
}
|
|
|
|
/// <summary>Gets or sets the specified index element in the underlying buffer.</summary>
|
|
/// <returns>The value of the specified index element in the underlying buffer.</returns>
|
|
/// <param name="offset">The array index element of the desired information. </param>
|
|
/// <exception cref="T:System.IndexOutOfRangeException">The specified index does not exist in the buffer. </exception>
|
|
// Token: 0x17000706 RID: 1798
|
|
public byte this[int offset]
|
|
{
|
|
get
|
|
{
|
|
return this.data[offset];
|
|
}
|
|
set
|
|
{
|
|
this.data[offset] = value;
|
|
}
|
|
}
|
|
|
|
/// <summary>Returns information about the socket address.</summary>
|
|
/// <returns>A string that contains information about the <see cref="T:System.Net.SocketAddress" />.</returns>
|
|
/// <PermissionSet>
|
|
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode" />
|
|
/// </PermissionSet>
|
|
// Token: 0x06001577 RID: 5495 RVA: 0x00044DEC File Offset: 0x00042FEC
|
|
public override string ToString()
|
|
{
|
|
string text = ((global::System.Net.Sockets.AddressFamily)this.data[0]).ToString();
|
|
int num = this.data.Length;
|
|
string text2 = string.Concat(new object[] { text, ":", num, ":{" });
|
|
for (int i = 2; i < num; i++)
|
|
{
|
|
int num2 = (int)this.data[i];
|
|
text2 += num2;
|
|
if (i < num - 1)
|
|
{
|
|
text2 += ",";
|
|
}
|
|
}
|
|
return text2 + "}";
|
|
}
|
|
|
|
/// <summary>Determines whether the specified <see cref="T:System.Object" /> is equal to the current <see cref="T:System.Net.SocketAddress" /> instance.</summary>
|
|
/// <returns>true if the specified <see cref="T:System.Object" /> is equal to the current <see cref="T:System.Object" />; otherwise, false.</returns>
|
|
/// <param name="comparand">The specified <see cref="T:System.Object" /> to compare with the current <see cref="T:System.Net.SocketAddress" /> instance.</param>
|
|
// Token: 0x06001578 RID: 5496 RVA: 0x00044E8C File Offset: 0x0004308C
|
|
public override bool Equals(object obj)
|
|
{
|
|
SocketAddress socketAddress = obj as SocketAddress;
|
|
if (socketAddress != null && socketAddress.data.Length == this.data.Length)
|
|
{
|
|
byte[] array = socketAddress.data;
|
|
for (int i = 0; i < this.data.Length; i++)
|
|
{
|
|
if (array[i] != this.data[i])
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
/// <summary>Serves as a hash function for a particular type, suitable for use in hashing algorithms and data structures like a hash table.</summary>
|
|
/// <returns>A hash code for the current <see cref="T:System.Object" />.</returns>
|
|
// Token: 0x06001579 RID: 5497 RVA: 0x00044EF0 File Offset: 0x000430F0
|
|
public override int GetHashCode()
|
|
{
|
|
int num = 0;
|
|
for (int i = 0; i < this.data.Length; i++)
|
|
{
|
|
num += (int)this.data[i] + i;
|
|
}
|
|
return num;
|
|
}
|
|
|
|
// Token: 0x040011D1 RID: 4561
|
|
private byte[] data;
|
|
}
|
|
}
|