private void btConnect_Click(object sender, EventArgs e) { client = new Client(); client.MessageReceieved += HandleMess; client.SendUDPRequest(); if (client.IsConnected) { cbIsConnected.Checked = true; tbIPAdress.Text = ((IPEndPoint)client.TCPsocket.RemoteEndPoint).Address.ToString(); tbName.ReadOnly = tbPassword.ReadOnly = true; btConnect.Enabled = false; btDisconnect.Enabled = true; client.JoinChat(tbName.Text, tbPassword.Text.GetHashCode()); } }