/// <summary> /// Begins an operation to accept a connection request from the client /// </summary> /// <param name="e">The context object to use when issuing the accept operation on the server's listening socket</param> private void StartAccept(SocketAsyncEventArgs e) { if (e == null) { e = new SocketAsyncEventArgs(); e.Completed += (sender, completedE) => AcceptCompleted(completedE); } else { // socket must be cleared since the context object is being reused e.AcceptSocket = null; } _connectionLimit.WaitOne(); try { if (MainSocket.AcceptAsync(e) == false) { AcceptCompleted(e); } } catch (ObjectDisposedException) { // ignored } }