internal void OnEvent_NewConnection(IAsyncResult iAr) { try { Socket socket = ((Socket)iAr.AsyncState).EndAccept(iAr); String ip = socket.RemoteEndPoint.ToString().Split(':')[0]; if (allowedIps.Contains(ip)) { MusConnection nC = new MusConnection(socket); } else { socket.Close(); } } catch (Exception) { } msSocket.BeginAccept(OnEvent_NewConnection, msSocket); }