in Win RT we have to use DatagramSocket instead of UdpClient. Ok but the following code gives me this error which I don't get on UdpClient.
var g = new DatagramSocket();
g.MessageReceived += g_MessageReceived;
await g.BindEndpointAsync(new HostName("0.0.0.0"), "5000"); //<--- this line
*IPAddress.Any = 0.0.0.0
I get this Error: "No such host is known. (Exception from HRESULT: 0x80072AF9)"
To bind to all local interfaces (the way binding 0.0.0.0 aka INADDR_ANY does with the Berkeley Sockets API), use BindServiceNameAsync
.
The
BindServiceNameAsync
method binds to the local IP addresses of all network interfaces on the local computer on the local service name or UDP port specified in thelocalServiceName
parameter. If thelocalServiceName
parameter is an empty string, the system will select the local UDP port on which to bind.