// This is the truly async version that uses AcceptEx. internal IAsyncResult BeginAccept(Socket acceptSocket, int receiveSize, AsyncCallback callback, object state) { if (s_loggingEnabled) { Logging.Enter(Logging.Sockets, this, "BeginAccept", ""); } if (CleanedUp) { throw new ObjectDisposedException(this.GetType().FullName); } // Validate input parameters. if (receiveSize < 0) { throw new ArgumentOutOfRangeException("size"); } // 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 (s_loggingEnabled) { Logging.Exit(Logging.Sockets, this, "BeginAccept", asyncResult); } return asyncResult; }
public IAsyncResult BeginAccept(Socket acceptSocket, int receiveSize, AsyncCallback callback, object state) { if (Socket.s_LoggingEnabled) Logging.Enter(Logging.Sockets, (object) this, "BeginAccept", ""); if (this.CleanedUp) throw new ObjectDisposedException(this.GetType().FullName); if (receiveSize < 0) throw new ArgumentOutOfRangeException("size"); AcceptOverlappedAsyncResult asyncResult = new AcceptOverlappedAsyncResult(this, state, callback); asyncResult.StartPostingAsyncOp(false); this.DoBeginAccept(acceptSocket, receiveSize, asyncResult); asyncResult.FinishPostingAsyncOp(ref this.Caches.AcceptClosureCache); if (Socket.s_LoggingEnabled) Logging.Exit(Logging.Sockets, (object) this, "BeginAccept", (object) asyncResult); return (IAsyncResult) asyncResult; }