I want to listen port 80. For this, I coded a TCP listener and gave it admin rights. But it doesn't work (it fails).
Therefore if port 12375 is not being used by anything, it would not be listed. As I said, if you don't have a firewall enabled, all ports should be open. It is not the case that ports are by default inaccessible and that you have to make them accessible in some way, but the exact opposite - unless you do something to prevent the use of a port it will be usable.
This is the error:
My code:
3 Answers
I suspect port 80 is already in use by either IIS or maybe Skype.You will need to turn them off or change the port they use.
Run this and figure out which process (PID) is using port 80:
If the PID points to the System process (4 in my case), then that is IIS I believe.
For even more detail, wrap your server.Start() call in a try/catch and catch SocketException and examine the SocketException.ErrorCode.
Port 80 is used by IIS (default) if you have IIS in your machine then follow this link https://stackoverflow.com/a/108397/1221319 to stop IIS from listening port 80.
As far I know, to bind a TCP connection through the port 80, you need to get the administrator privileges.So, you must run your program as administrator, and the HttpListener
you're using should work correctly.Try adding this to your manifest file: