///<summary>Called when there's an incoming client connection waiting to be accepted.</summary> ///<param name="ar">The result of the asynchronous operation.</param> public override void OnAccept(IAsyncResult ar) { try { Socket NewSocket = ListenSocket.EndAccept(ar); if (NewSocket != null) { HttpClient NewClient = new HttpClient(NewSocket, new DestroyDelegate(this.RemoveClient)); AddClient(NewClient); NewClient.StartHandshake(); } } catch {} try { //Restart Listening ListenSocket.BeginAccept(new AsyncCallback(this.OnAccept), ListenSocket); } catch { Dispose(); } }