Guest User

Untitled

a guest
Aug 30th, 2016
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.59 KB | None | 0 0
  1. private void buttonEnviar_Click(object sender, EventArgs e)
  2. {
  3.     byte[] temp = System.Text.Encoding.UTF8.GetBytes(textBoxClient.Text.ToCharArray()); //Convertendo a mensagem para bytes e armazenando
  4.     bufferOfClient = BitConverter.GetBytes(0); //Id do pacote, esse contém apenas uma mensagem
  5.     Buffer.BlockCopy(BitConverter.GetBytes(temp.Length), 0, bufferOfClient, 4, BitConverter.GetBytes(temp.Length).Length); //Armazenando a quantidade de bytes da mensagem
  6.     Buffer.BlockCopy(temp, 0, bufferOfClient, 8, temp.Length); //Armazenando a string
  7.     socketOfClient.Send(bufferOfClient);
  8. }
Add Comment
Please, Sign In to add comment