public BeginReceive ( byte buffer, int offset, int size, SocketFlags socketFlags, AsyncCallback callback, object state ) : IAsyncResult | ||
buffer | byte | The storage location for the received data. |
offset | int | The zero-based position in the buffer parameter at which to store the received data. |
size | int | The number of bytes to receive. |
socketFlags | SocketFlags | A bitwise combination of the |
callback | AsyncCallback | The |
state | object | An object containing state information for this request. |
Результат | IAsyncResult |
///<summary>Starts the authentication process.</summary> ///<param name="Connection">The connection with the SOCKS client.</param> ///<param name="Callback">The method to call when the authentication is complete.</param> internal override void StartAuthentication(SecureSocket Connection, AuthenticationCompleteDelegate Callback) { this.Connection = Connection; this.Callback = Callback; try { Bytes = null; Connection.BeginReceive(Buffer, 0, Buffer.Length, SocketFlags.None, new AsyncCallback(this.OnRecvRequest), Connection); } catch { Callback(false); } }
/// <summary> /// Begins an asynchronous read from a stream. /// </summary> /// <param name="buffer">The location in memory that stores the data from the stream.</param> /// <param name="offset">The location in buffer to begin storing the data to.</param> /// <param name="size">The maximum number of bytes to read.</param> /// <param name="callback">The delegate to call when the asynchronous call is complete.</param> /// <param name="state">An object containing additional information supplied by the client.</param> /// <returns>An <see cref="IAsyncResult"/> representing the asynchronous call.</returns> /// <exception cref="ArgumentNullException"><paramref name="buffer"/> is a null reference (<b>Nothing</b> in Visual Basic).</exception> /// <exception cref="ArgumentOutOfRangeException">The specified <paramref name="offset"/> or <paramref name="size"/> exceeds the size of <paramref name="buffer"/>.</exception> /// <exception cref="IOException">There is a failure while reading from the network.</exception> public override IAsyncResult BeginRead(byte[] buffer, int offset, int size, AsyncCallback callback, object state) { if (buffer == null) { throw new ArgumentNullException(); } if (offset < 0 || offset > buffer.Length || size < 0 || size > buffer.Length - offset) { throw new ArgumentOutOfRangeException(); } if (Socket == null) { throw new IOException(); } try { return(Socket.BeginReceive(buffer, offset, size, SocketFlags.None, callback, state)); } catch (Exception e) { throw new IOException("An I/O exception occurred.", e); } }