Skip to content

Instantly share code, notes, and snippets.

@mrtank
Created April 9, 2020 14:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrtank/46f2d9aa713646ddcbefde8b1111d36f to your computer and use it in GitHub Desktop.
Save mrtank/46f2d9aa713646ddcbefde8b1111d36f to your computer and use it in GitHub Desktop.
static void Main(string[] args)
{
UdpClient udpClient = new UdpClient();
udpClient.Connect(new IPEndPoint(IPAddress.Broadcast, 11000));
Byte[] sendBytes = Encoding.ASCII.GetBytes("Is anybody there?");
udpClient.Send(sendBytes, sendBytes.Length);
}
static void Main(string[] args)
{
IPEndPoint remoteIpEndPoint = new IPEndPoint(IPAddress.Any, 0);
UdpClient udpClient = new UdpClient(11000);
Byte[] receiveBytes = udpClient.Receive(ref remoteIpEndPoint);
NetworkStream stream = new NetworkStream(udpClient.Client); // <- 'System.IO.IOException' The operation is not allowed on non-connected sockets thrown here.
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment