private void btn_AddDevice_Click(object sender, EventArgs e) { if (txt_DeviceIPV4.Text.Length < 6) { txt_DeviceIPV4.Focus(); label3.Text = "请输入添加设备的IP地址"; return; } IPAddress ipAddress = null; try { ipAddress = IPAddress.Parse(txt_DeviceIPV4.Text); } catch (Exception) { label3.Text = "ip地址格式不正确,请使用正确的ip地址!"; return; } tcpClient.ConnectAsync(ipAddress.ToString(), 65005); this.Close(); }
private void btnConn_Click(object sender, EventArgs e) { client.ConnectAsync(txtIp.Text, Convert.ToInt32(txtPort.Text)); }