private void RecieveAndBroadCast(Socket client) { while (true) { try { byte[] bytes = new Byte[1024]; int recBytes = client.Receive(bytes); // Blocking //var player = _players.Single(x => x.Client.RemoteEndPoint == client.RemoteEndPoint); if (recBytes == 0) { //_players.Remove(player); SocketHelper.BroadCast(client, Encoding.UTF8.GetBytes("Opponent disconnected")); break; // klienten stängd => 0 } var nettoBytes = (bytes.Take(recBytes)).ToArray <byte>(); string response = Encoding.UTF8.GetString(bytes, 0, recBytes); SocketHelper.BroadCast(client, nettoBytes); //Console.WriteLine(player.Symbol + " sending: " + response); } catch { break; } } }