private void btnDesconectar_Click(object sender, EventArgs e) { ClienteTCP.Desconectar(txtIdentificador.Text); lblEstado.Text = "Desconectado"; lblEstado.ForeColor = Color.Red; btnDesconectar.Enabled = false; btnConectar.Enabled = true; clienteConectado = false; txtIdentificador.ReadOnly = false; }
// public object ClienteTCP { get; private set; } private void btnConectar_Click(object sender, EventArgs e) { if (!(txtIdentificador.Text.Equals(string.Empty))) { if (ClienteTCP.Conectar(txtIdentificador.Text)) { lblEstado.Text = "Conectado al servidor... en (127.0.0.1, 30000)"; lblEstado.ForeColor = Color.Green; clienteConectado = true; btnConectar.Enabled = false; btnDesconectar.Enabled = true; txtIdentificador.ReadOnly = true; } else { MessageBox.Show("Verifique que el servidor esté escuchando clientes...", "No es posible conectarse", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { MessageBox.Show("Debe ingresar el identificador del cliente", "Atención", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }