Esempio n. 1
0
        private void btn_Login_Click(object sender, EventArgs e)
        {
            Data msgToSend = new Data();

            msgToSend.cmdCommand = Command.Login;
            msgToSend.strName    = strName;

            DialogResult = DialogResult.OK;

            byte[] b = msgToSend.ToByte();

            //Send the message to the server
            clientSocket?.BeginSend(b, 0, b.Length, SocketFlags.None, new AsyncCallback(OnSend), null);

            //clientSocket?.BeginReceive(byteData, 0, byteData.Length, SocketFlags.None, new AsyncCallback(OnReceive), null);

            DialogResult = DialogResult.OK;
            Close();
        }
Esempio n. 2
0
 private static void Send(Socket client, String data)
 {
     byte[] byteData = Encoding.ASCII.GetBytes(data);
     client.BeginSend(byteData, 0, byteData.Length, 0, new AsyncCallback(SendCallback), client);
 }
Esempio n. 3
0
 public void Send(string message)
 {
     byte[] data = Encoding.ASCII.GetBytes(message);
     _buffer = data;
     _socket.BeginSend(_buffer, 0, _buffer.Length, 0, new AsyncCallback(SendCallback), null);
 }
Esempio n. 4
0
 public void SendToServer(string data)
 {
     buff = Encoding.ASCII.GetBytes(data);
     serverSocket.BeginSend(buff, 0, buff.Length, SocketFlags.None, new AsyncCallback(SendCallback), serverSocket);
 }
Esempio n. 5
0
 private void LoginButton_Click(object sender, RoutedEventArgs e)
 {
     byte[] data = Encoding.ASCII.GetBytes("login " + UsernameIn.Text + " " + PasswordIn.Text);
     ClientSocket.BeginSend(data, 0, data.Length, SocketFlags.None, null, null);
 }
Esempio n. 6
0
 public void Send()
 {
     buff = Encoding.ASCII.GetBytes(txtChat.Text);
     clientSocket.BeginSend(buff, 0, buff.Length, SocketFlags.None, new AsyncCallback(SendCallback), clientSocket);
 }
Esempio n. 7
0
        void SendData(string content)
        {
            var data = Encoding.ASCII.GetBytes(content);

            client.BeginSend(data, 0, data.Length, SocketFlags.None, new AsyncCallback(SendCallBack), client);
        }
Esempio n. 8
0
 private void btnSend_Click(object sender, EventArgs e)
 {
     data = Encoding.ASCII.GetBytes(txtMS.Text);
     ClientSock.BeginSend(data, 0, data.Length, SocketFlags.None, new AsyncCallback(SendData), ClientSock);
     txtMS.Text = "";
 }
Esempio n. 9
0
        private void button2_Click(object sender, EventArgs e)
        {
            var msg = Encoding.Unicode.GetBytes(textBoxMsg.Text);

            serverSocket.BeginSend(msg, 0, msg.Length, SocketFlags.None, null, null);
        }