This commit is contained in:
niko
2026-06-04 11:42:34 +02:00
parent f39ba70a9f
commit e720b98cd1
7488 changed files with 2493818 additions and 0 deletions
+754
View File
@@ -0,0 +1,754 @@
using System;
namespace System.Net.Sockets
{
/// <summary>Provides client connections for TCP network services.</summary>
// Token: 0x020001F6 RID: 502
public class TcpClient : IDisposable
{
/// <summary>Initializes a new instance of the <see cref="T:System.Net.Sockets.TcpClient" /> class.</summary>
// Token: 0x060010C0 RID: 4288 RVA: 0x00030A8C File Offset: 0x0002EC8C
public TcpClient()
{
this.Init(AddressFamily.InterNetwork);
this.client.Bind(new IPEndPoint(IPAddress.Any, 0));
}
/// <summary>Initializes a new instance of the <see cref="T:System.Net.Sockets.TcpClient" /> class with the specified family.</summary>
/// <param name="family">The <see cref="P:System.Net.IPAddress.AddressFamily" /> of the IP protocol. </param>
/// <exception cref="T:System.ArgumentException">The <paramref name="family" /> parameter is not equal to AddressFamily.InterNetwork -or- The <paramref name="family" /> parameter is not equal to AddressFamily.InterNetworkV6 </exception>
// Token: 0x060010C1 RID: 4289 RVA: 0x00030AB4 File Offset: 0x0002ECB4
public TcpClient(AddressFamily family)
{
if (family != AddressFamily.InterNetwork && family != AddressFamily.InterNetworkV6)
{
throw new ArgumentException("Family must be InterNetwork or InterNetworkV6", "family");
}
this.Init(family);
IPAddress ipaddress = IPAddress.Any;
if (family == AddressFamily.InterNetworkV6)
{
ipaddress = IPAddress.IPv6Any;
}
this.client.Bind(new IPEndPoint(ipaddress, 0));
}
/// <summary>Initializes a new instance of the <see cref="T:System.Net.Sockets.TcpClient" /> class and binds it to the specified local endpoint.</summary>
/// <param name="localEP">The <see cref="T:System.Net.IPEndPoint" /> to which you bind the TCP <see cref="T:System.Net.Sockets.Socket" />. </param>
/// <exception cref="T:System.ArgumentNullException">The <paramref name="localEP" /> parameter is null. </exception>
// Token: 0x060010C2 RID: 4290 RVA: 0x00030B14 File Offset: 0x0002ED14
public TcpClient(IPEndPoint local_end_point)
{
this.Init(local_end_point.AddressFamily);
this.client.Bind(local_end_point);
}
/// <summary>Initializes a new instance of the <see cref="T:System.Net.Sockets.TcpClient" /> class and connects to the specified port on the specified host.</summary>
/// <param name="hostname">The DNS name of the remote host to which you intend to connect. </param>
/// <param name="port">The port number of the remote host to which you intend to connect. </param>
/// <exception cref="T:System.ArgumentNullException">The <paramref name="hostname" /> parameter is null. </exception>
/// <exception cref="T:System.ArgumentOutOfRangeException">The <paramref name="port" /> parameter is not between <see cref="F:System.Net.IPEndPoint.MinPort" /> and <see cref="F:System.Net.IPEndPoint.MaxPort" />. </exception>
/// <exception cref="T:System.Net.Sockets.SocketException">An error occurred when accessing the socket. See the Remarks section for more information. </exception>
// Token: 0x060010C3 RID: 4291 RVA: 0x00030B40 File Offset: 0x0002ED40
public TcpClient(string hostname, int port)
{
this.Connect(hostname, port);
}
/// <summary>Releases all resources used by the <see cref="T:System.Net.Sockets.TcpClient" />. </summary>
// Token: 0x060010C4 RID: 4292 RVA: 0x00030B50 File Offset: 0x0002ED50
void IDisposable.Dispose()
{
this.Dispose(true);
GC.SuppressFinalize(this);
}
// Token: 0x060010C5 RID: 4293 RVA: 0x00030B60 File Offset: 0x0002ED60
private void Init(AddressFamily family)
{
this.active = false;
if (this.client != null)
{
this.client.Close();
this.client = null;
}
this.client = new Socket(family, SocketType.Stream, ProtocolType.Tcp);
}
/// <summary>Gets or set a value that indicates whether a connection has been made.</summary>
/// <returns>true if the connection has been made; otherwise, false.</returns>
// Token: 0x17000593 RID: 1427
// (get) Token: 0x060010C6 RID: 4294 RVA: 0x00030BA0 File Offset: 0x0002EDA0
// (set) Token: 0x060010C7 RID: 4295 RVA: 0x00030BA8 File Offset: 0x0002EDA8
protected bool Active
{
get
{
return this.active;
}
set
{
this.active = value;
}
}
/// <summary>Gets or sets the underlying <see cref="T:System.Net.Sockets.Socket" />.</summary>
/// <returns>The underlying network <see cref="T:System.Net.Sockets.Socket" />.</returns>
// Token: 0x17000594 RID: 1428
// (get) Token: 0x060010C8 RID: 4296 RVA: 0x00030BB4 File Offset: 0x0002EDB4
// (set) Token: 0x060010C9 RID: 4297 RVA: 0x00030BBC File Offset: 0x0002EDBC
public Socket Client
{
get
{
return this.client;
}
set
{
this.client = value;
this.stream = null;
}
}
/// <summary>Gets the amount of data that has been received from the network and is available to be read.</summary>
/// <returns>The number of bytes of data received from the network and available to be read.</returns>
/// <exception cref="T:System.Net.Sockets.SocketException">An error occurred when attempting to access the socket. See the Remarks section for more information. </exception>
/// <exception cref="T:System.ObjectDisposedException">The <see cref="T:System.Net.Sockets.Socket" /> has been closed. </exception>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.EnvironmentPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode, ControlEvidence" />
/// </PermissionSet>
// Token: 0x17000595 RID: 1429
// (get) Token: 0x060010CA RID: 4298 RVA: 0x00030BCC File Offset: 0x0002EDCC
public int Available
{
get
{
return this.client.Available;
}
}
/// <summary>Gets a value indicating whether the underlying <see cref="T:System.Net.Sockets.Socket" /> for a <see cref="T:System.Net.Sockets.TcpClient" /> is connected to a remote host.</summary>
/// <returns>true if the <see cref="P:System.Net.Sockets.TcpClient.Client" /> socket was connected to a remote resource as of the most recent operation; otherwise, false.</returns>
// Token: 0x17000596 RID: 1430
// (get) Token: 0x060010CB RID: 4299 RVA: 0x00030BDC File Offset: 0x0002EDDC
public bool Connected
{
get
{
return this.client.Connected;
}
}
/// <summary>Gets or sets a <see cref="T:System.Boolean" /> value that specifies whether the <see cref="T:System.Net.Sockets.TcpClient" /> allows only one client to use a port.</summary>
/// <returns>true if the <see cref="T:System.Net.Sockets.TcpClient" /> allows only one client to use a specific port; otherwise, false. The default is true for Windows Server 2003 and Windows XP Service Pack 2 and later, and false for all other versions.</returns>
/// <exception cref="T:System.Net.Sockets.SocketException">An error occurred when attempting to access the underlying socket.</exception>
/// <exception cref="T:System.ObjectDisposedException">The underlying <see cref="T:System.Net.Sockets.Socket" /> has been closed. </exception>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.EnvironmentPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// </PermissionSet>
// Token: 0x17000597 RID: 1431
// (get) Token: 0x060010CC RID: 4300 RVA: 0x00030BEC File Offset: 0x0002EDEC
// (set) Token: 0x060010CD RID: 4301 RVA: 0x00030BFC File Offset: 0x0002EDFC
public bool ExclusiveAddressUse
{
get
{
return this.client.ExclusiveAddressUse;
}
set
{
this.client.ExclusiveAddressUse = value;
}
}
// Token: 0x060010CE RID: 4302 RVA: 0x00030C0C File Offset: 0x0002EE0C
internal void SetTcpClient(Socket s)
{
this.Client = s;
}
/// <summary>Gets or sets information on the linger state of the associated socket.</summary>
/// <returns>A <see cref="T:System.Net.Sockets.LingerOption" />. By default, lingering is disabled.</returns>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.EnvironmentPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// </PermissionSet>
// Token: 0x17000598 RID: 1432
// (get) Token: 0x060010CF RID: 4303 RVA: 0x00030C18 File Offset: 0x0002EE18
// (set) Token: 0x060010D0 RID: 4304 RVA: 0x00030C54 File Offset: 0x0002EE54
public LingerOption LingerState
{
get
{
if ((this.values & TcpClient.Properties.LingerState) != (TcpClient.Properties)0U)
{
return this.linger_state;
}
return (LingerOption)this.client.GetSocketOption(SocketOptionLevel.Socket, SocketOptionName.Linger);
}
set
{
if (!this.client.Connected)
{
this.linger_state = value;
this.values |= TcpClient.Properties.LingerState;
return;
}
this.client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.Linger, value);
}
}
/// <summary>Gets or sets a value that disables a delay when send or receive buffers are not full.</summary>
/// <returns>true if the delay is disabled, otherwise false. The default value is false.</returns>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.EnvironmentPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// </PermissionSet>
// Token: 0x17000599 RID: 1433
// (get) Token: 0x060010D1 RID: 4305 RVA: 0x00030CA0 File Offset: 0x0002EEA0
// (set) Token: 0x060010D2 RID: 4306 RVA: 0x00030CD4 File Offset: 0x0002EED4
public bool NoDelay
{
get
{
if ((this.values & TcpClient.Properties.NoDelay) != (TcpClient.Properties)0U)
{
return this.no_delay;
}
return (bool)this.client.GetSocketOption(SocketOptionLevel.Tcp, SocketOptionName.Debug);
}
set
{
if (!this.client.Connected)
{
this.no_delay = value;
this.values |= TcpClient.Properties.NoDelay;
return;
}
this.client.SetSocketOption(SocketOptionLevel.Tcp, SocketOptionName.Debug, (!value) ? 0 : 1);
}
}
/// <summary>Gets or sets the size of the receive buffer.</summary>
/// <returns>The size of the receive buffer, in bytes. The default value is 8192 bytes.</returns>
/// <exception cref="T:System.Net.Sockets.SocketException">An error occurred when setting the buffer size.-or-In .NET Compact Framework applications, you cannot set this property. For a workaround, see the Platform Note in Remarks.</exception>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.EnvironmentPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// </PermissionSet>
// Token: 0x1700059A RID: 1434
// (get) Token: 0x060010D3 RID: 4307 RVA: 0x00030D24 File Offset: 0x0002EF24
// (set) Token: 0x060010D4 RID: 4308 RVA: 0x00030D60 File Offset: 0x0002EF60
public int ReceiveBufferSize
{
get
{
if ((this.values & TcpClient.Properties.ReceiveBufferSize) != (TcpClient.Properties)0U)
{
return this.recv_buffer_size;
}
return (int)this.client.GetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReceiveBuffer);
}
set
{
if (!this.client.Connected)
{
this.recv_buffer_size = value;
this.values |= TcpClient.Properties.ReceiveBufferSize;
return;
}
this.client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReceiveBuffer, value);
}
}
/// <summary>Gets or sets the amount of time a <see cref="T:System.Net.Sockets.TcpClient" /> will wait to receive data once a read operation is initiated.</summary>
/// <returns>The time-out value of the connection in milliseconds. The default value is 0.</returns>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.EnvironmentPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// </PermissionSet>
// Token: 0x1700059B RID: 1435
// (get) Token: 0x060010D5 RID: 4309 RVA: 0x00030DAC File Offset: 0x0002EFAC
// (set) Token: 0x060010D6 RID: 4310 RVA: 0x00030DE8 File Offset: 0x0002EFE8
public int ReceiveTimeout
{
get
{
if ((this.values & TcpClient.Properties.ReceiveTimeout) != (TcpClient.Properties)0U)
{
return this.recv_timeout;
}
return (int)this.client.GetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReceiveTimeout);
}
set
{
if (!this.client.Connected)
{
this.recv_timeout = value;
this.values |= TcpClient.Properties.ReceiveTimeout;
return;
}
this.client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReceiveTimeout, value);
}
}
/// <summary>Gets or sets the size of the send buffer.</summary>
/// <returns>The size of the send buffer, in bytes. The default value is 8192 bytes.</returns>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.EnvironmentPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// </PermissionSet>
// Token: 0x1700059C RID: 1436
// (get) Token: 0x060010D7 RID: 4311 RVA: 0x00030E34 File Offset: 0x0002F034
// (set) Token: 0x060010D8 RID: 4312 RVA: 0x00030E68 File Offset: 0x0002F068
public int SendBufferSize
{
get
{
if ((this.values & TcpClient.Properties.SendBufferSize) != (TcpClient.Properties)0U)
{
return this.send_buffer_size;
}
return (int)this.client.GetSocketOption(SocketOptionLevel.Socket, SocketOptionName.SendBuffer);
}
set
{
if (!this.client.Connected)
{
this.send_buffer_size = value;
this.values |= TcpClient.Properties.SendBufferSize;
return;
}
this.client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.SendBuffer, value);
}
}
/// <summary>Gets or sets the amount of time a <see cref="T:System.Net.Sockets.TcpClient" /> will wait for a send operation to complete successfully.</summary>
/// <returns>The send time-out value, in milliseconds. The default is 0.</returns>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.EnvironmentPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// </PermissionSet>
// Token: 0x1700059D RID: 1437
// (get) Token: 0x060010D9 RID: 4313 RVA: 0x00030EA8 File Offset: 0x0002F0A8
// (set) Token: 0x060010DA RID: 4314 RVA: 0x00030EDC File Offset: 0x0002F0DC
public int SendTimeout
{
get
{
if ((this.values & TcpClient.Properties.SendTimeout) != (TcpClient.Properties)0U)
{
return this.send_timeout;
}
return (int)this.client.GetSocketOption(SocketOptionLevel.Socket, SocketOptionName.SendTimeout);
}
set
{
if (!this.client.Connected)
{
this.send_timeout = value;
this.values |= TcpClient.Properties.SendTimeout;
return;
}
this.client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.SendTimeout, value);
}
}
/// <summary>Disposes this <see cref="T:System.Net.Sockets.TcpClient" /> instance and requests that the underlying TCP connection be closed.</summary>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.EnvironmentPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode, ControlEvidence" />
/// </PermissionSet>
// Token: 0x060010DB RID: 4315 RVA: 0x00030F1C File Offset: 0x0002F11C
public void Close()
{
((IDisposable)this).Dispose();
}
/// <summary>Connects the client to a remote TCP host using the specified remote network endpoint.</summary>
/// <param name="remoteEP">The <see cref="T:System.Net.IPEndPoint" /> to which you intend to connect. </param>
/// <exception cref="T:System.ArgumentNullException">The <paramref name="remoteEp" /> parameter is null. </exception>
/// <exception cref="T:System.Net.Sockets.SocketException">An error occurred when accessing the socket. See the Remarks section for more information. </exception>
/// <exception cref="T:System.ObjectDisposedException">The <see cref="T:System.Net.Sockets.TcpClient" /> is closed. </exception>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.EnvironmentPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// <IPermission class="System.Diagnostics.PerformanceCounterPermission, System, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// <IPermission class="System.Net.SocketPermission, System, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// </PermissionSet>
// Token: 0x060010DC RID: 4316 RVA: 0x00030F24 File Offset: 0x0002F124
public void Connect(IPEndPoint remote_end_point)
{
try
{
this.client.Connect(remote_end_point);
this.active = true;
}
finally
{
this.CheckDisposed();
}
}
/// <summary>Connects the client to a remote TCP host using the specified IP address and port number.</summary>
/// <param name="address">The <see cref="T:System.Net.IPAddress" /> of the host to which you intend to connect. </param>
/// <param name="port">The port number to which you intend to connect. </param>
/// <exception cref="T:System.ArgumentNullException">The <paramref name="address" /> parameter is null. </exception>
/// <exception cref="T:System.ArgumentOutOfRangeException">The <paramref name="port" /> is not between <see cref="F:System.Net.IPEndPoint.MinPort" /> and <see cref="F:System.Net.IPEndPoint.MaxPort" />. </exception>
/// <exception cref="T:System.Net.Sockets.SocketException">An error occurred when accessing the socket. See the Remarks section for more information. </exception>
/// <exception cref="T:System.ObjectDisposedException">
/// <see cref="T:System.Net.Sockets.TcpClient" /> is closed. </exception>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.EnvironmentPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// <IPermission class="System.Diagnostics.PerformanceCounterPermission, System, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// <IPermission class="System.Net.SocketPermission, System, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// </PermissionSet>
// Token: 0x060010DD RID: 4317 RVA: 0x00030F6C File Offset: 0x0002F16C
public void Connect(IPAddress address, int port)
{
this.Connect(new IPEndPoint(address, port));
}
// Token: 0x060010DE RID: 4318 RVA: 0x00030F7C File Offset: 0x0002F17C
private void SetOptions()
{
TcpClient.Properties properties = this.values;
this.values = (TcpClient.Properties)0U;
if ((properties & TcpClient.Properties.LingerState) != (TcpClient.Properties)0U)
{
this.LingerState = this.linger_state;
}
if ((properties & TcpClient.Properties.NoDelay) != (TcpClient.Properties)0U)
{
this.NoDelay = this.no_delay;
}
if ((properties & TcpClient.Properties.ReceiveBufferSize) != (TcpClient.Properties)0U)
{
this.ReceiveBufferSize = this.recv_buffer_size;
}
if ((properties & TcpClient.Properties.ReceiveTimeout) != (TcpClient.Properties)0U)
{
this.ReceiveTimeout = this.recv_timeout;
}
if ((properties & TcpClient.Properties.SendBufferSize) != (TcpClient.Properties)0U)
{
this.SendBufferSize = this.send_buffer_size;
}
if ((properties & TcpClient.Properties.SendTimeout) != (TcpClient.Properties)0U)
{
this.SendTimeout = this.send_timeout;
}
}
/// <summary>Connects the client to the specified port on the specified host.</summary>
/// <param name="hostname">The DNS name of the remote host to which you intend to connect. </param>
/// <param name="port">The port number of the remote host to which you intend to connect. </param>
/// <exception cref="T:System.ArgumentNullException">The <paramref name="hostname" /> parameter is null. </exception>
/// <exception cref="T:System.ArgumentOutOfRangeException">The <paramref name="port" /> parameter is not between <see cref="F:System.Net.IPEndPoint.MinPort" /> and <see cref="F:System.Net.IPEndPoint.MaxPort" />. </exception>
/// <exception cref="T:System.Net.Sockets.SocketException">An error occurred when accessing the socket. See the Remarks section for more information. </exception>
/// <exception cref="T:System.ObjectDisposedException">
/// <see cref="T:System.Net.Sockets.TcpClient" /> is closed. </exception>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.EnvironmentPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// <IPermission class="System.Diagnostics.PerformanceCounterPermission, System, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// <IPermission class="System.Net.SocketPermission, System, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// </PermissionSet>
// Token: 0x060010DF RID: 4319 RVA: 0x00031014 File Offset: 0x0002F214
public void Connect(string hostname, int port)
{
IPAddress[] hostAddresses = Dns.GetHostAddresses(hostname);
this.Connect(hostAddresses, port);
}
/// <summary>Connects the client to a remote TCP host using the specified IP addresses and port number.</summary>
/// <param name="ipAddresses">The <see cref="T:System.Net.IPAddress" /> array of the host to which you intend to connect.</param>
/// <param name="port">The port number to which you intend to connect.</param>
/// <exception cref="T:System.ArgumentNullException">The <paramref name="ipAddresses" /> parameter is null. </exception>
/// <exception cref="T:System.ArgumentOutOfRangeException">The port number is not valid.</exception>
/// <exception cref="T:System.Net.Sockets.SocketException">An error occurred when attempting to access the socket. See the Remarks section for more information. </exception>
/// <exception cref="T:System.ObjectDisposedException">The <see cref="T:System.Net.Sockets.Socket" /> has been closed. </exception>
/// <exception cref="T:System.Security.SecurityException">A caller higher in the call stack does not have permission for the requested operation. </exception>
/// <exception cref="T:System.NotSupportedException">This method is valid for sockets that use the <see cref="F:System.Net.Sockets.AddressFamily.InterNetwork" /> flag or the <see cref="F:System.Net.Sockets.AddressFamily.InterNetworkV6" /> flag.</exception>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.EnvironmentPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// <IPermission class="System.Diagnostics.PerformanceCounterPermission, System, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// <IPermission class="System.Net.SocketPermission, System, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// </PermissionSet>
// Token: 0x060010E0 RID: 4320 RVA: 0x00031030 File Offset: 0x0002F230
public void Connect(IPAddress[] ipAddresses, int port)
{
this.CheckDisposed();
if (ipAddresses == null)
{
throw new ArgumentNullException("ipAddresses");
}
for (int i = 0; i < ipAddresses.Length; i++)
{
try
{
IPAddress ipaddress = ipAddresses[i];
if (ipaddress.Equals(IPAddress.Any) || ipaddress.Equals(IPAddress.IPv6Any))
{
throw new SocketException(10049);
}
this.Init(ipaddress.AddressFamily);
if (ipaddress.AddressFamily == AddressFamily.InterNetwork)
{
this.client.Bind(new IPEndPoint(IPAddress.Any, 0));
}
else
{
if (ipaddress.AddressFamily != AddressFamily.InterNetworkV6)
{
throw new NotSupportedException("This method is only valid for sockets in the InterNetwork and InterNetworkV6 families");
}
this.client.Bind(new IPEndPoint(IPAddress.IPv6Any, 0));
}
this.Connect(new IPEndPoint(ipaddress, port));
if (this.values != (TcpClient.Properties)0U)
{
this.SetOptions();
}
break;
}
catch (Exception ex)
{
this.Init(AddressFamily.InterNetwork);
if (i == ipAddresses.Length - 1)
{
throw ex;
}
}
}
}
/// <summary>Asynchronously accepts an incoming connection attempt.</summary>
/// <param name="asyncResult">An <see cref="T:System.IAsyncResult" /> object returned by a call to <see cref="Overload:System.Net.Sockets.TcpClient.BeginConnect" />.</param>
/// <exception cref="T:System.ArgumentNullException">The <paramref name="asyncResult" /> parameter is null. </exception>
/// <exception cref="T:System.ArgumentException">The <paramref name="asyncResult" /> parameter was not returned by a call to a <see cref="Overload:System.Net.Sockets.TcpClient.BeginConnect" /> method. </exception>
/// <exception cref="T:System.InvalidOperationException">The <see cref="M:System.Net.Sockets.TcpClient.EndConnect(System.IAsyncResult)" /> method was previously called for the asynchronous connection. </exception>
/// <exception cref="T:System.Net.Sockets.SocketException">An error occurred when attempting to access the <see cref="T:System.Net.Sockets.Socket" />. See the Remarks section for more information. </exception>
/// <exception cref="T:System.ObjectDisposedException">The underlying <see cref="T:System.Net.Sockets.Socket" /> has been closed. </exception>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.EnvironmentPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode, ControlEvidence" />
/// </PermissionSet>
// Token: 0x060010E1 RID: 4321 RVA: 0x0003115C File Offset: 0x0002F35C
public void EndConnect(IAsyncResult asyncResult)
{
this.client.EndConnect(asyncResult);
}
/// <summary>Begins an asynchronous request for a remote host connection. The remote host is specified by an <see cref="T:System.Net.IPAddress" /> and a port number (<see cref="T:System.Int32" />).</summary>
/// <returns>An <see cref="T:System.IAsyncResult" /> object that references the asynchronous connection.</returns>
/// <param name="address">The <see cref="T:System.Net.IPAddress" /> of the remote host.</param>
/// <param name="port">The port number of the remote host.</param>
/// <param name="requestCallback">An <see cref="T:System.AsyncCallback" /> delegate that references the method to invoke when the operation is complete. </param>
/// <param name="state">A user-defined object that contains information about the connect operation. This object is passed to the <paramref name="requestCallback" /> delegate when the operation is complete.</param>
/// <exception cref="T:System.ArgumentNullException">The <paramref name="address" /> parameter is null. </exception>
/// <exception cref="T:System.Net.Sockets.SocketException">An error occurred when attempting to access the socket. See the Remarks section for more information. </exception>
/// <exception cref="T:System.ObjectDisposedException">The <see cref="T:System.Net.Sockets.Socket" /> has been closed. </exception>
/// <exception cref="T:System.Security.SecurityException">A caller higher in the call stack does not have permission for the requested operation. </exception>
/// <exception cref="T:System.ArgumentOutOfRangeException">The port number is not valid.</exception>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.EnvironmentPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// <IPermission class="System.Diagnostics.PerformanceCounterPermission, System, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// <IPermission class="System.Net.SocketPermission, System, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// </PermissionSet>
// Token: 0x060010E2 RID: 4322 RVA: 0x0003116C File Offset: 0x0002F36C
public IAsyncResult BeginConnect(IPAddress address, int port, AsyncCallback callback, object state)
{
return this.client.BeginConnect(address, port, callback, state);
}
/// <summary>Begins an asynchronous request for a remote host connection. The remote host is specified by an <see cref="T:System.Net.IPAddress" /> array and a port number (<see cref="T:System.Int32" />).</summary>
/// <returns>An <see cref="T:System.IAsyncResult" /> object that references the asynchronous connection.</returns>
/// <param name="addresses">At least one <see cref="T:System.Net.IPAddress" /> that designates the remote hosts.</param>
/// <param name="port">The port number of the remote hosts.</param>
/// <param name="requestCallback">An <see cref="T:System.AsyncCallback" /> delegate that references the method to invoke when the operation is complete.</param>
/// <param name="state">A user-defined object that contains information about the connect operation. This object is passed to the <paramref name="requestCallback" /> delegate when the operation is complete.</param>
/// <exception cref="T:System.ArgumentNullException">The <paramref name="addresses" /> parameter is null. </exception>
/// <exception cref="T:System.Net.Sockets.SocketException">An error occurred when attempting to access the socket. See the Remarks section for more information. </exception>
/// <exception cref="T:System.ObjectDisposedException">The <see cref="T:System.Net.Sockets.Socket" /> has been closed. </exception>
/// <exception cref="T:System.Security.SecurityException">A caller higher in the call stack does not have permission for the requested operation. </exception>
/// <exception cref="T:System.ArgumentOutOfRangeException">The port number is not valid.</exception>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.EnvironmentPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// <IPermission class="System.Diagnostics.PerformanceCounterPermission, System, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// <IPermission class="System.Net.SocketPermission, System, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// </PermissionSet>
// Token: 0x060010E3 RID: 4323 RVA: 0x00031180 File Offset: 0x0002F380
public IAsyncResult BeginConnect(IPAddress[] addresses, int port, AsyncCallback callback, object state)
{
return this.client.BeginConnect(addresses, port, callback, state);
}
/// <summary>Begins an asynchronous request for a remote host connection. The remote host is specified by a host name (<see cref="T:System.String" />) and a port number (<see cref="T:System.Int32" />).</summary>
/// <returns>An <see cref="T:System.IAsyncResult" /> object that references the asynchronous connection.</returns>
/// <param name="host">The name of the remote host.</param>
/// <param name="port">The port number of the remote host.</param>
/// <param name="requestCallback">An <see cref="T:System.AsyncCallback" /> delegate that references the method to invoke when the operation is complete.</param>
/// <param name="state">A user-defined object that contains information about the connect operation. This object is passed to the <paramref name="requestCallback" /> delegate when the operation is complete.</param>
/// <exception cref="T:System.ArgumentNullException">The <paramref name="host" /> parameter is null. </exception>
/// <exception cref="T:System.Net.Sockets.SocketException">An error occurred when attempting to access the socket. See the Remarks section for more information. </exception>
/// <exception cref="T:System.ObjectDisposedException">The <see cref="T:System.Net.Sockets.Socket" /> has been closed. </exception>
/// <exception cref="T:System.Security.SecurityException">A caller higher in the call stack does not have permission for the requested operation. </exception>
/// <exception cref="T:System.ArgumentOutOfRangeException">The port number is not valid.</exception>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.EnvironmentPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// <IPermission class="System.Diagnostics.PerformanceCounterPermission, System, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// <IPermission class="System.Net.SocketPermission, System, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// </PermissionSet>
// Token: 0x060010E4 RID: 4324 RVA: 0x00031194 File Offset: 0x0002F394
public IAsyncResult BeginConnect(string host, int port, AsyncCallback callback, object state)
{
return this.client.BeginConnect(host, port, callback, state);
}
/// <summary>Releases the unmanaged resources used by the <see cref="T:System.Net.Sockets.TcpClient" /> and optionally releases the managed resources.</summary>
/// <param name="disposing">Set to true to release both managed and unmanaged resources; false to release only unmanaged resources. </param>
// Token: 0x060010E5 RID: 4325 RVA: 0x000311A8 File Offset: 0x0002F3A8
protected virtual void Dispose(bool disposing)
{
if (this.disposed)
{
return;
}
this.disposed = true;
if (disposing)
{
NetworkStream networkStream = this.stream;
this.stream = null;
if (networkStream != null)
{
networkStream.Close();
this.active = false;
}
else if (this.client != null)
{
this.client.Close();
this.client = null;
}
}
}
/// <summary>Frees resources used by the <see cref="T:System.Net.Sockets.TcpClient" /> class.</summary>
// Token: 0x060010E6 RID: 4326 RVA: 0x00031214 File Offset: 0x0002F414
~TcpClient()
{
this.Dispose(false);
}
/// <summary>Returns the <see cref="T:System.Net.Sockets.NetworkStream" /> used to send and receive data.</summary>
/// <returns>The underlying <see cref="T:System.Net.Sockets.NetworkStream" />.</returns>
/// <exception cref="T:System.InvalidOperationException">The <see cref="T:System.Net.Sockets.TcpClient" /> is not connected to a remote host. </exception>
/// <exception cref="T:System.ObjectDisposedException">The <see cref="T:System.Net.Sockets.TcpClient" /> has been closed. </exception>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.EnvironmentPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode, ControlEvidence" />
/// </PermissionSet>
// Token: 0x060010E7 RID: 4327 RVA: 0x00031250 File Offset: 0x0002F450
public NetworkStream GetStream()
{
NetworkStream networkStream;
try
{
if (this.stream == null)
{
this.stream = new NetworkStream(this.client, true);
}
networkStream = this.stream;
}
finally
{
this.CheckDisposed();
}
return networkStream;
}
// Token: 0x060010E8 RID: 4328 RVA: 0x000312B0 File Offset: 0x0002F4B0
private void CheckDisposed()
{
if (this.disposed)
{
throw new ObjectDisposedException(base.GetType().FullName);
}
}
// Token: 0x04000F29 RID: 3881
private NetworkStream stream;
// Token: 0x04000F2A RID: 3882
private bool active;
// Token: 0x04000F2B RID: 3883
private Socket client;
// Token: 0x04000F2C RID: 3884
private bool disposed;
// Token: 0x04000F2D RID: 3885
private TcpClient.Properties values;
// Token: 0x04000F2E RID: 3886
private int recv_timeout;
// Token: 0x04000F2F RID: 3887
private int send_timeout;
// Token: 0x04000F30 RID: 3888
private int recv_buffer_size;
// Token: 0x04000F31 RID: 3889
private int send_buffer_size;
// Token: 0x04000F32 RID: 3890
private LingerOption linger_state;
// Token: 0x04000F33 RID: 3891
private bool no_delay;
// Token: 0x020001F7 RID: 503
private enum Properties : uint
{
// Token: 0x04000F35 RID: 3893
LingerState = 1U,
// Token: 0x04000F36 RID: 3894
NoDelay,
// Token: 0x04000F37 RID: 3895
ReceiveBufferSize = 4U,
// Token: 0x04000F38 RID: 3896
ReceiveTimeout = 8U,
// Token: 0x04000F39 RID: 3897
SendBufferSize = 16U,
// Token: 0x04000F3A RID: 3898
SendTimeout = 32U
}
}
}