private void loginButton_Click(object sender, EventArgs e) { if ((usernameBox.Text.Length < 3) || (passwordBox.Text.Length < 3)) return; else { LoginData msgToSend = new LoginData(); msgToSend.strUsername = usernameBox.Text; msgToSend.strPassword = passwordBox.Text; msgToSend.cmdCommand = Command.NewLogin; byte[] byteData = msgToSend.ToByte(); clientSocket.BeginSend(byteData, 0, byteData.Length, SocketFlags.None, new AsyncCallback(OnSend), null); txtMessage.Text = null; } }