public void Start(string server, string port) { try { session = new GameSession(); var tcpClient = new SimpleTcpClient().Connect(server, int.Parse(port)); Log("tcp client connected to server"); var handshakeCommand = new HandshakeCommand { me = $"player{new Random().Next(1000)} {punter.GetType().Name}" }; Log($"Begin handshake as {handshakeCommand.me}"); var reply = tcpClient.WriteAndGetReply(serializer.Serialize(handshakeCommand), TimeSpan.MaxValue); session.Status = GameStatus.Setup; tcpClient.DataReceived += TcpClient_DataReceived; var handshakeMessage = serializer.Deserialize <HandshakeMessage>(reply.MessageString); if (handshakeMessage.you != handshakeCommand.me) { throw new Exception($"me: {handshakeCommand.me}, you: {handshakeMessage.you}"); } } catch (Exception e) { Log(e.ToString()); } }