public IAsyncResult BeginAccept(Socket acceptSocket, int receiveSize, AsyncCallback callback, object state)
{
if (NetEventSource.IsEnabled) NetEventSource.Enter(this);
if (CleanedUp)
{
throw new ObjectDisposedException(this.GetType().FullName);
}
// Validate input parameters.
if (receiveSize < 0)
{
throw new ArgumentOutOfRangeException(nameof(receiveSize));
}
// Set up the async result with flowing.
AcceptOverlappedAsyncResult asyncResult = new AcceptOverlappedAsyncResult(this, state, callback);
asyncResult.StartPostingAsyncOp(false);
// Start the accept.
DoBeginAccept(acceptSocket, receiveSize, asyncResult);
// Finish the flow capture, maybe complete here.
asyncResult.FinishPostingAsyncOp(ref Caches.AcceptClosureCache);
if (NetEventSource.IsEnabled) NetEventSource.Exit(this, asyncResult);
return asyncResult;
}