Esempio n. 1
0
 private void btConnect_Click(object sender, EventArgs e)
 {
     if (String.IsNullOrEmpty(txUserName.Text))
     {
         MessageBox.Show("Enter your user name pls!!");
         return;
     }
     try
     {
         client = new SocketClientHelper(txUserName.Text, int.Parse(txPort.Text));
         client.Connect();
         client.socket.BeginReceive(buffer, 0, buffer.Length, SocketFlags.None, new AsyncCallback(ReceiveCallBack), client.socket);
         btConnect.Text = (btConnect.Text == "Connect") ? "Disconnect" : "Connect";
         connected      = true;
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }