private void btnReg_Click(object sender, EventArgs e) { String username = txtRegUsername.Text.Trim(); String password = txtRegPass.Text.Trim(); String confirmpassword = txtRegCfmPass.Text.Trim(); String email = txtRegEmail.Text.Trim(); if (username == string.Empty || password == string.Empty || confirmpassword == string.Empty || email == string.Empty) { MessageBox.Show("Please enter all the fields!"); return; } else { if (password != confirmpassword) { MessageBox.Show("Passwords do not match."); return; } else { try { string responseString = ClientConnect.Register(Main.serverAddress, Main.serverPort, username, password, email); responseString = responseString.Trim('\0').Trim('\n'); MessageBox.Show(responseString); this.Close(); } catch (System.Net.Sockets.SocketException) { MessageBox.Show("Could not connect to the server!"); return; } //Old code /*if (ClientConnect.Register(Main.serverAddress, Main.serverPort, username, password, email)) * { * txtRegUsername.Text = ""; * txtRegPass.Text = ""; * txtRegCfmPass.Text=""; * txtRegEmail.Text=""; * MessageBox.Show("Registration Successful!"); * } * else * { * MessageBox.Show("Registration Failed!"); * }*/ } } }