Exemple #1
0
 private void btnConnect_Click(object sender, EventArgs e)
 {
     btnConnect.Enabled = false;
     try
     {
         client.Connect(txtHost.Text, Convert.ToInt32(txtPort.Text));
         txtStatus.Text += "Connected to " + txtHost.Text + ":" + txtPort.Text + " successfully!" + Environment.NewLine;
     } catch (System.Net.Sockets.SocketException ex)
     {
         txtStatus.Text    += ex.Message + Environment.NewLine;
         btnConnect.Enabled = true;
     }
 }
Exemple #2
0
 private void b_Connect_Click(object sender, EventArgs e)
 {
     try
     {
         client.Connect(tb_host.Text, int.Parse(tb_port.Text));
         b_Connect.Enabled   = false;
         b_UnConnect.Enabled = true;
         tb_Status.Text     += "\r\nПодключено...\r\n";
     }
     catch (Exception err)
     {
         MessageBox.Show(err.Message, "Ошибка");
     }
 }
 private void btnConnect_Click(object sender, EventArgs e)
 {
     btnConnect.Enabled = false;
     try
     {
         client.Connect(txtHost.Text, int.Parse(txtPort.Text));
         client.WriteLine("Client connected!");
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message.ToString());
         btnConnect.Enabled = true;
     }
 }
 private void btnConnect_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         client.Connect("127.0.0.1", 1111);
         client.Write(">>> " + username + " just joined! <<<\n");
         btnConnect.IsEnabled        = false;
         connectedToTheServerAs.Text = "You are connected to the server as: " + username; //Connected to server as message
     }
     catch (Exception ex)                                                                 //if the server is anactive but the user still presses the connect button
     {
         System.Windows.MessageBox.Show("Server is not active");
         btnConnect.IsEnabled = true;
     }
 }
Exemple #5
0
        private void Client_Load(object sender, EventArgs e)
        {
            client = new SimpleTcpClient();
            client.StringEncoder = Encoding.UTF8;
            client.DataReceived += clientDataRecieved;

            try
            {
                client.Connect(ip, Convert.ToInt32(port));
            }
            catch
            {
                this.Hide();
                MessageBox.Show("Could not connect to the server!" + Environment.NewLine + "Please ensure your firewall is disabled.", "Client", MessageBoxButtons.OK);
                Application.Exit();
            }
        }
Exemple #6
0
 private void Form1_Load(object sender, EventArgs e)
 {
     try
     {
         client = new SimpleTcpClient();
         //client.StringEncoder = Encoding.UTF8;
         string ip   = Convert.ToString(txtHostClient.Text);
         int    port = Convert.ToInt32(txtPortClient.Text);
         client.Connect(ip, port);
         client.DataReceived += Client_DataSender;
         // client.DataReceived += Client_DataReceivedDraw;
     }
     catch (Exception ex)
     {
         // Console.WriteLine("Listen thread exception!! " + ex.Message);
     }
 }
Exemple #7
0
 public void bconnect_Click(object sender, EventArgs e)
 {
     if (txtname.Text == "")
     {
         MessageBox.Show("Insert Name!");
     }
     else if (nsv != "y")
     {
         MessageBox.Show("Click Save Name!");
     }
     else if (nsv == "y")
     {
         try{
             Client.Connect(txthost.Text, Convert.ToInt32(txtport.Text));
             Client.Write("User:"******";" + " is connected to server");
             cn = "y";
             bconnect.Enabled = false;
         }
         catch
         {
             MessageBox.Show("Can't connect to server");
         }
     }
 }
        private void ConnBtn_Click(object sender, RoutedEventArgs e)
        {
            if (client != null)
            {
                MessageBox.Show("접속중");
            }
            else
            {
                try
                {//닉네임 공백 체크
                    //IP가 IP형식이 맞는지...
                    if (int.TryParse(portTxt.Text, out int port) == false)
                    {
                        MessageBox.Show("포트 숫자 아님"); return;
                    }

                    //if (String.IsNullOrWhiteSpace(nickNameTxt.Text))
                    //{
                    //    MessageBox.Show("닉네임 공백 있음"); return;
                    //}

                    //if(IPAddress.TryParse(ipTxt.Text,out IPAddress ip) == false)
                    //{
                    //    MessageBox.Show("IP 형식 아님"); return;
                    //}

                    client = new SimpleTcpClient(ipTxt.Text, port, nickNameTxt.Text);
                    client.OnMessageReceived += Client_OnMessageReceived;
                    client.Connect();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
Exemple #9
0
 private void btnConnect_Click(object sender, EventArgs e)
 {
     btnConnect.Enabled = false;
     //Connect to server
     client.Connect(txtHost.Text, Convert.ToInt32(txtPort.Text));
 }
 private void btnConnect_Click(object sender, EventArgs e)
 {
     btnConnect.Enabled = false;
     _client.Connect(txtIP.Text, int.Parse(txtPort.Text));
 }
Exemple #11
0
 private void cl_conectBT_Click_1(object sender, EventArgs e)
 {
     cl_DataLogTB.Text  += "Connected...";
     cl_conectBT.Enabled = false;
     client.Connect(cl_IPaddressTB.Text, Convert.ToInt32(cl_portTB.Text));
 }
 private void btnConnect_Click(object sender, RoutedEventArgs e)
 {
     btnConnect.IsEnabled = false; //prevents us from clicking the button
     client.Connect(txtHost.Text, Convert.ToInt32(txtPort.Text));
     client.Write("                         " + username + " just joined!\n");
 }
Exemple #13
0
 private void btnConnect_Click(object sender, EventArgs e)
 {
     client.Connect(txtIp.Text.ToString(), Int32.Parse(txtPort.Text));
     btnConnect.Enabled = false;
     login_btn.Enabled  = true;
 }