SimpleTCP icon indicating copy to clipboard operation
SimpleTCP copied to clipboard

Add option to listen on 0.0.0.0 instead of individually on all interfaces

Open brudo opened this issue 8 years ago • 2 comments

I am suggesting to add an option to bind 0.0.0.0 to listen on all interfaces in SimpleTcpServer, instead of itemizing the interfaces and listening on each one individually. This would work well on Windows but might not be supported on all platforms, e.g. Linux, so you may need to make this configurable through an optional parameter, or have the check which OS at run time, or have it try 0.0.0.0 and fall back to individual interfaces if that fails. Thoughts?

brudo avatar Oct 26 '17 17:10 brudo

What would be the advantages of 0.0.0.0 vs individual interfaces?

BrandonPotter avatar Oct 26 '17 23:10 BrandonPotter

Avoids having to enumerate interfaces and listen separately on each, and dealing with any errors on each interface, but I guess that’s more of an internal detail (that I see as beneficial), not a use case. It’s how I usually bind on Windows by default, i.e. IPAddress.Any, unless configured otherwise. If I’m not mistaken - and I could be wrong - it could also handle cases where a network interface comes online or gets reconfigured after the server has been started.

There are other differences; whether they are advantageous or not depends on context. Can be overridden by bindings for specific interfaces, when you want that. Will not silently override another service listening on same port, e.g. if the other service is listening on the same port on 0.0.0.0, your bindings on each interface will take precedence, IIRC.

brudo avatar Oct 27 '17 06:10 brudo