public ClientGUI(string host, string name) { InitializeComponent(); socket = new ClientSocket(); socket.Start(IPAddress.Parse(host), 3306); //socket.Start("127.0.0.1", 11000); //socket.Start(Dns.GetHostEntry(Dns.GetHostName()).AddressList[0], 11000); thread = new Thread(GetMessage); thread.Start(); socket.SendMessage(name); }
private void button1_Click(object sender, EventArgs e) { socket.SendMessage(textBox1.Text); textBox1.Text = ""; }
// Send a Message to the Server! private void buttonSend_Click(object sender, EventArgs e) { try { IPAddress ipadd; if (IPAddress.TryParse(textIp.Text, out ipadd)) { _ipaddress = textIp.Text; _portnumber = uint.Parse(textPort.Text); ClientSocket c = new ClientSocket(_ipaddress, _portnumber); if(textBoxMessage.Text.Length != 0) { String returnMessage = c.SendMessage(textBoxMessage.Text); MessageBox.Show("Attempting to Send Message\nServer Response: " + returnMessage, "Send Message To Server", MessageBoxButtons.OK); } else MessageBox.Show("Please enter some text to send", "Warning", MessageBoxButtons.OK); } else MessageBox.Show("Not a valid IP Address"); } catch(System.FormatException ex) { MessageBox.Show("Not a valid Port Number", ex.Message, MessageBoxButtons.OK, MessageBoxIcon.Error); } catch(Exception ex){ MessageBox.Show(ex.Message, "Send Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }