I'm trying to get UDP messages send from clients in network, but when I create a new UdpClient I always get the exception:
System.Net.Sockets.SocketException: 'Access denied'
My Code for this very simple and woring perfect on console application, but not in Xamarin App.
public void Demo()
{
var Server = new UdpClient(80);
var ResponseData = Encoding.ASCII.GetBytes("SomeResponseData");
while (true)
{
var ClientEp = new IPEndPoint(IPAddress.Any, 0);
var ClientRequestData = Server.Receive(ref ClientEp);
var ClientRequest = Encoding.ASCII.GetString(ClientRequestData);
Console.WriteLine("Recived {0} from {1}, sending response", ClientRequest, ClientEp.Address.ToString());
Server.Send(ResponseData, ResponseData.Length, ClientEp);
}
}
I also saw this posting but this did not help me at all.
I'm using Android 11 for testing.
CodePudding user response:
I found another post, this so you cant bind port 80 if you did not root your device.