Created
April 9, 2020 14:03
-
-
Save mrtank/46f2d9aa713646ddcbefde8b1111d36f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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