问题
I trying to run this code:
listener = new TcpListener(IPAddress.Any,port: 80);
listener.Start();
socket = listener.AcceptSocket();
but it throws the following exception: An attempt was made to access a socket in a way forbidden by its access permissions
What may be the reason?
回答1:
It might be forbidden to use a port below 1024 if you are not Administrator. Try a port like 8080 instead. see also Which port can i use for my socket?
来源:https://stackoverflow.com/questions/23593077/socket-exception-in-tcp-listener