BeginReceive() 공개 메소드

Begins to asynchronously receive data from a connected SecureSocket.
is a null reference (Nothing in Visual Basic). An operating system error occurs while accessing the SecureSocket. SecureSocket has been closed. The offset parameter is outside the bounds of buffer or size is either smaller or larger than the buffer size.
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 values.
callback AsyncCallback The delegate.
state object An object containing state information for this request.
리턴 IAsyncResult
예제 #1
0
	///<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);
     }
 }