void ConnectButton_Click(object sender, EventArgs e) { if (!client.connected) { try { Console.WriteLine("Connecting to " + ipAddress + ": " + port + "..."); if (client.Connect(ipAddress, port)) { Thread.Sleep(10); client.ProcessResponse(); client.ConnectPacket(userName); SendToChat("You have connected to the server.", bold: true); NameTextBox.ReadOnly = false; InputField.ReadOnly = false; } else { SendToChat("There was an error connecting to the server.", bold: true); } } catch (Exception ex) { SendToChat("There was an error connecting to the server: " + ex.Message, bold: true); } } }