public void AcceptCallback(IAsyncResult ar) { try { Socket acceptSocket = s.EndAccept(ar); //handoff accepting to acceptSocket to free up main socket ClientsControl.AddClient(acceptSocket); //create client object add them to total list of clients s.BeginAccept(AcceptCallback, s); //start accepting another connection after handoff } catch (Exception ex) { throw new Exception("Base accept error" + ex); } }
public void disconnect() { _receiveSocket.Disconnect(true); ClientsControl.RemoveClient(_clientid); //remove by index if connection closed }