Advertisement
Guest User

Untitled

a guest
Jun 26th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. byte[] messagebuffer = Encoding.ASCII.GetBytes(txtMessage.Text);
  2. stream.Write(messagebuffer, 0, messagebuffer.Length);
  3.  
  4. socket = new Socket(AddressFamily.InterNetwork, SocketType.Raw, ProtocolType.IP);
  5. socket.Bind(new IPEndPoint(IPAddress.Parse(comboBox1.SelectedItem.ToString()), int.Parse(tbPort.Text)));
  6. socket.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.HeaderIncluded, true);
  7.  
  8. byte[] byInc = new byte[] { 1, 0, 0, 0 };
  9. byte[] byOut = new byte[4];
  10. buffer = new byte[4096];
  11. socket.IOControl(IOControlCode.ReceiveAll, byInc, byOut);
  12. socket.BeginReceive(buffer, 0, buffer.Length, SocketFlags.None, OnReceive, null);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement