Socket exception in tcp listener

こ雲淡風輕ζ 提交于 2019-12-24 11:49:14

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!