private void ReciveCallback(IAsyncResult AR) { try { Socket socket = (Socket)AR.AsyncState; int received = socket.EndReceive(AR); byte[] dataBuff = new byte[received]; Array.Copy(_buffer, dataBuff, received); string text = Encoding.ASCII.GetString(dataBuff); clientsConnected.Add(text); AppendToTextBox(text + " has connected."); playersConnected++; Player p = new Player(playersConnected, text); p.AddPlayer(p); socket.BeginSend(dataBuff, 0, dataBuff.Length, SocketFlags.None, new AsyncCallback(SendCallback), socket); socket.BeginReceive(_buffer, 0, _buffer.Length, SocketFlags.None, new AsyncCallback(ReciveCallback), null); } catch (Exception ex) { MessageBox.Show(ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); } }