scripts
This commit is contained in:
@@ -0,0 +1,387 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
|
||||
namespace System.Net.Sockets
|
||||
{
|
||||
/// <summary>Represents an asynchronous socket operation.</summary>
|
||||
// Token: 0x020001EA RID: 490
|
||||
public class SocketAsyncEventArgs : EventArgs, IDisposable
|
||||
{
|
||||
// Token: 0x06001084 RID: 4228 RVA: 0x0003018C File Offset: 0x0002E38C
|
||||
internal SocketAsyncEventArgs(bool policy)
|
||||
: this()
|
||||
{
|
||||
this.PolicyRestricted = policy;
|
||||
}
|
||||
|
||||
/// <summary>Creates an empty <see cref="T:System.Net.Sockets.SocketAsyncEventArgs" /> instance.</summary>
|
||||
/// <exception cref="T:System.NotSupportedException">The platform is not supported. </exception>
|
||||
// Token: 0x06001085 RID: 4229 RVA: 0x0003019C File Offset: 0x0002E39C
|
||||
public SocketAsyncEventArgs()
|
||||
{
|
||||
this.AcceptSocket = null;
|
||||
this.Buffer = null;
|
||||
this.BufferList = null;
|
||||
this.BytesTransferred = 0;
|
||||
this.Count = 0;
|
||||
this.DisconnectReuseSocket = false;
|
||||
this.LastOperation = SocketAsyncOperation.None;
|
||||
this.Offset = 0;
|
||||
this.RemoteEndPoint = null;
|
||||
this.SendPacketsSendSize = -1;
|
||||
this.SocketError = SocketError.Success;
|
||||
this.SocketFlags = SocketFlags.None;
|
||||
this.UserToken = null;
|
||||
}
|
||||
|
||||
/// <summary>The event used to complete an asynchronous operation.</summary>
|
||||
// Token: 0x14000026 RID: 38
|
||||
// (add) Token: 0x06001086 RID: 4230 RVA: 0x0003020C File Offset: 0x0002E40C
|
||||
// (remove) Token: 0x06001087 RID: 4231 RVA: 0x00030228 File Offset: 0x0002E428
|
||||
public event EventHandler<SocketAsyncEventArgs> Completed;
|
||||
|
||||
/// <summary>Gets or sets the socket to use or the socket created for accepting a connection with an asynchronous socket method.</summary>
|
||||
/// <returns>The <see cref="T:System.Net.Sockets.Socket" /> to use or the socket created for accepting a connection with an asynchronous socket method.</returns>
|
||||
// Token: 0x1700057F RID: 1407
|
||||
// (get) Token: 0x06001088 RID: 4232 RVA: 0x00030244 File Offset: 0x0002E444
|
||||
// (set) Token: 0x06001089 RID: 4233 RVA: 0x0003024C File Offset: 0x0002E44C
|
||||
public Socket AcceptSocket { get; set; }
|
||||
|
||||
/// <summary>Gets the data buffer to use with an asynchronous socket method.</summary>
|
||||
/// <returns>A <see cref="T:System.Byte" /> array that represents the data buffer to use with an asynchronous socket method.</returns>
|
||||
// Token: 0x17000580 RID: 1408
|
||||
// (get) Token: 0x0600108A RID: 4234 RVA: 0x00030258 File Offset: 0x0002E458
|
||||
// (set) Token: 0x0600108B RID: 4235 RVA: 0x00030260 File Offset: 0x0002E460
|
||||
public byte[] Buffer { get; private set; }
|
||||
|
||||
/// <summary>Gets or sets an array of data buffers to use with an asynchronous socket method.</summary>
|
||||
/// <returns>An <see cref="T:System.Collections.IList" /> that represents an array of data buffers to use with an asynchronous socket method.</returns>
|
||||
/// <exception cref="T:System.ArgumentException">There are ambiguous buffers specified on a set operation. This exception occurs if a value other than null is passed and the <see cref="P:System.Net.Sockets.SocketAsyncEventArgs.Buffer" /> property is also not null.</exception>
|
||||
// Token: 0x17000581 RID: 1409
|
||||
// (get) Token: 0x0600108C RID: 4236 RVA: 0x0003026C File Offset: 0x0002E46C
|
||||
// (set) Token: 0x0600108D RID: 4237 RVA: 0x00030274 File Offset: 0x0002E474
|
||||
[global::System.MonoTODO("not supported in all cases")]
|
||||
public IList<ArraySegment<byte>> BufferList
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._bufferList;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (this.Buffer != null && value != null)
|
||||
{
|
||||
throw new ArgumentException("Buffer and BufferList properties cannot both be non-null.");
|
||||
}
|
||||
this._bufferList = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Gets the number of bytes transferred in the socket operation.</summary>
|
||||
/// <returns>An <see cref="T:System.Int32" /> that contains the number of bytes transferred in the socket operation.</returns>
|
||||
// Token: 0x17000582 RID: 1410
|
||||
// (get) Token: 0x0600108E RID: 4238 RVA: 0x0003029C File Offset: 0x0002E49C
|
||||
// (set) Token: 0x0600108F RID: 4239 RVA: 0x000302A4 File Offset: 0x0002E4A4
|
||||
public int BytesTransferred { get; private set; }
|
||||
|
||||
/// <summary>Gets the maximum amount of data, in bytes, to send or receive in an asynchronous operation.</summary>
|
||||
/// <returns>An <see cref="T:System.Int32" /> that contains the maximum amount of data, in bytes, to send or receive.</returns>
|
||||
// Token: 0x17000583 RID: 1411
|
||||
// (get) Token: 0x06001090 RID: 4240 RVA: 0x000302B0 File Offset: 0x0002E4B0
|
||||
// (set) Token: 0x06001091 RID: 4241 RVA: 0x000302B8 File Offset: 0x0002E4B8
|
||||
public int Count { get; private set; }
|
||||
|
||||
/// <summary>Gets or sets a value that specifies if socket can be reused after a disconnect operation.</summary>
|
||||
/// <returns>A <see cref="T:System.Boolean" /> that specifies if socket can be reused after a disconnect operation.</returns>
|
||||
// Token: 0x17000584 RID: 1412
|
||||
// (get) Token: 0x06001092 RID: 4242 RVA: 0x000302C4 File Offset: 0x0002E4C4
|
||||
// (set) Token: 0x06001093 RID: 4243 RVA: 0x000302CC File Offset: 0x0002E4CC
|
||||
public bool DisconnectReuseSocket { get; set; }
|
||||
|
||||
/// <summary>Gets the type of socket operation most recently performed with this context object.</summary>
|
||||
/// <returns>A <see cref="T:System.Net.Sockets.SocketAsyncOperation" /> instance that indicates the type of socket operation most recently performed with this context object.</returns>
|
||||
// Token: 0x17000585 RID: 1413
|
||||
// (get) Token: 0x06001094 RID: 4244 RVA: 0x000302D8 File Offset: 0x0002E4D8
|
||||
// (set) Token: 0x06001095 RID: 4245 RVA: 0x000302E0 File Offset: 0x0002E4E0
|
||||
public SocketAsyncOperation LastOperation { get; private set; }
|
||||
|
||||
/// <summary>Gets the offset, in bytes, into the data buffer referenced by the <see cref="P:System.Net.Sockets.SocketAsyncEventArgs.Buffer" /> property.</summary>
|
||||
/// <returns>An <see cref="T:System.Int32" /> that contains the offset, in bytes, into the data buffer referenced by the <see cref="P:System.Net.Sockets.SocketAsyncEventArgs.Buffer" /> property.</returns>
|
||||
// Token: 0x17000586 RID: 1414
|
||||
// (get) Token: 0x06001096 RID: 4246 RVA: 0x000302EC File Offset: 0x0002E4EC
|
||||
// (set) Token: 0x06001097 RID: 4247 RVA: 0x000302F4 File Offset: 0x0002E4F4
|
||||
public int Offset { get; private set; }
|
||||
|
||||
/// <summary>Gets or sets the remote IP endpoint for an asynchronous operation.</summary>
|
||||
/// <returns>An <see cref="T:System.Net.EndPoint" /> that represents the remote IP endpoint for an asynchronous operation.</returns>
|
||||
// Token: 0x17000587 RID: 1415
|
||||
// (get) Token: 0x06001098 RID: 4248 RVA: 0x00030300 File Offset: 0x0002E500
|
||||
// (set) Token: 0x06001099 RID: 4249 RVA: 0x00030308 File Offset: 0x0002E508
|
||||
public EndPoint RemoteEndPoint { get; set; }
|
||||
|
||||
/// <summary>Gets or sets the size, in bytes, of the data block used in the send operation.</summary>
|
||||
/// <returns>An <see cref="T:System.Int32" /> that contains the size, in bytes, of the data block used in the send operation.</returns>
|
||||
// Token: 0x17000588 RID: 1416
|
||||
// (get) Token: 0x0600109A RID: 4250 RVA: 0x00030314 File Offset: 0x0002E514
|
||||
// (set) Token: 0x0600109B RID: 4251 RVA: 0x0003031C File Offset: 0x0002E51C
|
||||
[global::System.MonoTODO("unused property")]
|
||||
public int SendPacketsSendSize { get; set; }
|
||||
|
||||
/// <summary>Gets or sets the result of the asynchronous socket operation.</summary>
|
||||
/// <returns>A <see cref="T:System.Net.Sockets.SocketError" /> that represents the result of the asynchronous socket operation.</returns>
|
||||
// Token: 0x17000589 RID: 1417
|
||||
// (get) Token: 0x0600109C RID: 4252 RVA: 0x00030328 File Offset: 0x0002E528
|
||||
// (set) Token: 0x0600109D RID: 4253 RVA: 0x00030330 File Offset: 0x0002E530
|
||||
public SocketError SocketError { get; set; }
|
||||
|
||||
/// <summary>Gets the results of an asynchronous socket operation or sets the behavior of an asynchronous operation.</summary>
|
||||
/// <returns>A <see cref="T:System.Net.Sockets.SocketFlags" /> that represents the results of an asynchronous socket operation.</returns>
|
||||
// Token: 0x1700058A RID: 1418
|
||||
// (get) Token: 0x0600109E RID: 4254 RVA: 0x0003033C File Offset: 0x0002E53C
|
||||
// (set) Token: 0x0600109F RID: 4255 RVA: 0x00030344 File Offset: 0x0002E544
|
||||
public SocketFlags SocketFlags { get; set; }
|
||||
|
||||
/// <summary>Gets or sets a user or application object associated with this asynchronous socket operation.</summary>
|
||||
/// <returns>An object that represents the user or application object associated with this asynchronous socket operation.</returns>
|
||||
// Token: 0x1700058B RID: 1419
|
||||
// (get) Token: 0x060010A0 RID: 4256 RVA: 0x00030350 File Offset: 0x0002E550
|
||||
// (set) Token: 0x060010A1 RID: 4257 RVA: 0x00030358 File Offset: 0x0002E558
|
||||
public object UserToken { get; set; }
|
||||
|
||||
// Token: 0x1700058C RID: 1420
|
||||
// (get) Token: 0x060010A2 RID: 4258 RVA: 0x00030364 File Offset: 0x0002E564
|
||||
public Socket ConnectSocket
|
||||
{
|
||||
get
|
||||
{
|
||||
SocketError socketError = this.SocketError;
|
||||
if (socketError != SocketError.AccessDenied)
|
||||
{
|
||||
return this.curSocket;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700058D RID: 1421
|
||||
// (get) Token: 0x060010A3 RID: 4259 RVA: 0x00030390 File Offset: 0x0002E590
|
||||
// (set) Token: 0x060010A4 RID: 4260 RVA: 0x00030398 File Offset: 0x0002E598
|
||||
internal bool PolicyRestricted { get; private set; }
|
||||
|
||||
/// <summary>Frees resources used by the <see cref="T:System.Net.Sockets.SocketAsyncEventArgs" /> class.</summary>
|
||||
// Token: 0x060010A5 RID: 4261 RVA: 0x000303A4 File Offset: 0x0002E5A4
|
||||
~SocketAsyncEventArgs()
|
||||
{
|
||||
this.Dispose(false);
|
||||
}
|
||||
|
||||
// Token: 0x060010A6 RID: 4262 RVA: 0x000303E0 File Offset: 0x0002E5E0
|
||||
private void Dispose(bool disposing)
|
||||
{
|
||||
Socket acceptSocket = this.AcceptSocket;
|
||||
if (acceptSocket != null)
|
||||
{
|
||||
acceptSocket.Close();
|
||||
}
|
||||
if (disposing)
|
||||
{
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Releases the unmanaged resources used by the <see cref="T:System.Net.Sockets.SocketAsyncEventArgs" /> instance and optionally disposes of the managed resources.</summary>
|
||||
// Token: 0x060010A7 RID: 4263 RVA: 0x0003040C File Offset: 0x0002E60C
|
||||
public void Dispose()
|
||||
{
|
||||
this.Dispose(true);
|
||||
}
|
||||
|
||||
/// <summary>Represents a method that is called when an asynchronous operation completes.</summary>
|
||||
/// <param name="e">The event that is signaled.</param>
|
||||
// Token: 0x060010A8 RID: 4264 RVA: 0x00030418 File Offset: 0x0002E618
|
||||
protected virtual void OnCompleted(SocketAsyncEventArgs e)
|
||||
{
|
||||
if (e == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
EventHandler<SocketAsyncEventArgs> completed = e.Completed;
|
||||
if (completed != null)
|
||||
{
|
||||
completed(e.curSocket, e);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Sets the data buffer to use with an asynchronous socket method.</summary>
|
||||
/// <param name="offset">The offset, in bytes, in the data buffer where the operation starts.</param>
|
||||
/// <param name="count">The maximum amount of data, in bytes, to send or receive in the buffer.</param>
|
||||
/// <exception cref="T:System.ArgumentException">There are ambiguous buffers specified. This exception occurs if the <see cref="P:System.Net.Sockets.SocketAsyncEventArgs.Buffer" /> property is also not null and the <see cref="P:System.Net.Sockets.SocketAsyncEventArgs.BufferList" /> property is also not null.</exception>
|
||||
/// <exception cref="T:System.ArgumentOutOfRangeException">An argument was out of range. This exception occurs if the <paramref name="offset" /> parameter is less than zero or greater than the length of the array in the <see cref="P:System.Net.Sockets.SocketAsyncEventArgs.Buffer" /> property. This exception also occurs if the <paramref name="count" /> parameter is less than zero or greater than the length of the array in the <see cref="P:System.Net.Sockets.SocketAsyncEventArgs.Buffer" /> property minus the <paramref name="offset" /> parameter.</exception>
|
||||
// Token: 0x060010A9 RID: 4265 RVA: 0x00030448 File Offset: 0x0002E648
|
||||
public void SetBuffer(int offset, int count)
|
||||
{
|
||||
this.SetBufferInternal(this.Buffer, offset, count);
|
||||
}
|
||||
|
||||
/// <summary>Sets the data buffer to use with an asynchronous socket method.</summary>
|
||||
/// <param name="buffer">The data buffer to use with an asynchronous socket method.</param>
|
||||
/// <param name="offset">The offset, in bytes, in the data buffer where the operation starts.</param>
|
||||
/// <param name="count">The maximum amount of data, in bytes, to send or receive in the buffer.</param>
|
||||
/// <exception cref="T:System.ArgumentException">There are ambiguous buffers specified. This exception occurs if the <see cref="P:System.Net.Sockets.SocketAsyncEventArgs.Buffer" /> property is also not null and the <see cref="P:System.Net.Sockets.SocketAsyncEventArgs.BufferList" /> property is also not null.</exception>
|
||||
/// <exception cref="T:System.ArgumentOutOfRangeException">An argument was out of range. This exception occurs if the <paramref name="offset" /> parameter is less than zero or greater than the length of the array in the <see cref="P:System.Net.Sockets.SocketAsyncEventArgs.Buffer" /> property. This exception also occurs if the <paramref name="count" /> parameter is less than zero or greater than the length of the array in the <see cref="P:System.Net.Sockets.SocketAsyncEventArgs.Buffer" /> property minus the <paramref name="offset" /> parameter.</exception>
|
||||
// Token: 0x060010AA RID: 4266 RVA: 0x00030458 File Offset: 0x0002E658
|
||||
public void SetBuffer(byte[] buffer, int offset, int count)
|
||||
{
|
||||
this.SetBufferInternal(buffer, offset, count);
|
||||
}
|
||||
|
||||
// Token: 0x060010AB RID: 4267 RVA: 0x00030464 File Offset: 0x0002E664
|
||||
private void SetBufferInternal(byte[] buffer, int offset, int count)
|
||||
{
|
||||
if (buffer != null)
|
||||
{
|
||||
if (this.BufferList != null)
|
||||
{
|
||||
throw new ArgumentException("Buffer and BufferList properties cannot both be non-null.");
|
||||
}
|
||||
int num = buffer.Length;
|
||||
if (offset < 0 || (offset != 0 && offset >= num))
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("offset");
|
||||
}
|
||||
if (count < 0 || count > num - offset)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("count");
|
||||
}
|
||||
this.Count = count;
|
||||
this.Offset = offset;
|
||||
}
|
||||
this.Buffer = buffer;
|
||||
}
|
||||
|
||||
// Token: 0x060010AC RID: 4268 RVA: 0x000304E0 File Offset: 0x0002E6E0
|
||||
private void ReceiveCallback()
|
||||
{
|
||||
this.SocketError = SocketError.Success;
|
||||
this.LastOperation = SocketAsyncOperation.Receive;
|
||||
SocketError socketError = SocketError.Success;
|
||||
if (!this.curSocket.Connected)
|
||||
{
|
||||
this.SocketError = SocketError.NotConnected;
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
this.BytesTransferred = this.curSocket.Receive_nochecks(this.Buffer, this.Offset, this.Count, this.SocketFlags, out socketError);
|
||||
}
|
||||
finally
|
||||
{
|
||||
this.SocketError = socketError;
|
||||
this.OnCompleted(this);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x060010AD RID: 4269 RVA: 0x00030574 File Offset: 0x0002E774
|
||||
private void ConnectCallback()
|
||||
{
|
||||
this.LastOperation = SocketAsyncOperation.Connect;
|
||||
SocketError socketError = SocketError.AccessDenied;
|
||||
try
|
||||
{
|
||||
socketError = this.TryConnect(this.RemoteEndPoint);
|
||||
}
|
||||
finally
|
||||
{
|
||||
this.SocketError = socketError;
|
||||
this.OnCompleted(this);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x060010AE RID: 4270 RVA: 0x000305CC File Offset: 0x0002E7CC
|
||||
private SocketError TryConnect(EndPoint endpoint)
|
||||
{
|
||||
this.curSocket.Connected = false;
|
||||
SocketError socketError = SocketError.Success;
|
||||
try
|
||||
{
|
||||
this.curSocket.seed_endpoint = endpoint;
|
||||
this.curSocket.Connect(endpoint);
|
||||
this.curSocket.Connected = true;
|
||||
}
|
||||
catch (SocketException ex)
|
||||
{
|
||||
socketError = ex.SocketErrorCode;
|
||||
}
|
||||
return socketError;
|
||||
}
|
||||
|
||||
// Token: 0x060010AF RID: 4271 RVA: 0x0003063C File Offset: 0x0002E83C
|
||||
private void SendCallback()
|
||||
{
|
||||
this.SocketError = SocketError.Success;
|
||||
this.LastOperation = SocketAsyncOperation.Send;
|
||||
SocketError socketError = SocketError.Success;
|
||||
if (!this.curSocket.Connected)
|
||||
{
|
||||
this.SocketError = SocketError.NotConnected;
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
if (this.Buffer != null)
|
||||
{
|
||||
this.BytesTransferred = this.curSocket.Send_nochecks(this.Buffer, this.Offset, this.Count, SocketFlags.None, out socketError);
|
||||
}
|
||||
else if (this.BufferList != null)
|
||||
{
|
||||
this.BytesTransferred = 0;
|
||||
foreach (ArraySegment<byte> arraySegment in this.BufferList)
|
||||
{
|
||||
this.BytesTransferred += this.curSocket.Send_nochecks(arraySegment.Array, arraySegment.Offset, arraySegment.Count, SocketFlags.None, out socketError);
|
||||
if (socketError != SocketError.Success)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
this.SocketError = socketError;
|
||||
this.OnCompleted(this);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x060010B0 RID: 4272 RVA: 0x00030774 File Offset: 0x0002E974
|
||||
internal void DoOperation(SocketAsyncOperation operation, Socket socket)
|
||||
{
|
||||
this.curSocket = socket;
|
||||
ThreadStart threadStart;
|
||||
switch (operation)
|
||||
{
|
||||
case SocketAsyncOperation.Connect:
|
||||
threadStart = new ThreadStart(this.ConnectCallback);
|
||||
goto IL_6A;
|
||||
case SocketAsyncOperation.Receive:
|
||||
threadStart = new ThreadStart(this.ReceiveCallback);
|
||||
goto IL_6A;
|
||||
case SocketAsyncOperation.Send:
|
||||
threadStart = new ThreadStart(this.SendCallback);
|
||||
goto IL_6A;
|
||||
}
|
||||
throw new NotSupportedException();
|
||||
IL_6A:
|
||||
new Thread(threadStart)
|
||||
{
|
||||
IsBackground = true
|
||||
}.Start();
|
||||
}
|
||||
|
||||
// Token: 0x04000E8D RID: 3725
|
||||
private IList<ArraySegment<byte>> _bufferList;
|
||||
|
||||
// Token: 0x04000E8E RID: 3726
|
||||
private Socket curSocket;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user