Guest User

Untitled

a guest
Jan 21st, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. IPEndPoint ProductEndPoint = new IPEndPoint(IPAddress.Any, 0);
  2. UdpClient host = new UdpClient();
  3. host.Client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true);
  4. host.Client.Bind(new IPEndPoint(IPAddress.Parse("192.168.0.1"), 67)); //192.168.0.1 is ip address of PC
  5.  
  6. for(int i = 0; i < 30; i++)
  7. {
  8. if (host.Available > 0)
  9. {
  10. byte[] Data = host.Receive(ref ProductEndPoint);
  11.  
  12. // Do something with the data
  13. }
  14. else
  15. Thread.Sleep(1000);
  16. }
Add Comment
Please, Sign In to add comment