unosquare / embedio

A tiny, cross-platform, module based web server for .NET
http://unosquare.github.io/embedio
Other
1.46k stars 176 forks source link

Choosing a random port #512

Closed gyorokpeter closed 3 years ago

gyorokpeter commented 3 years ago

Normally this is done by passing 0 to the TCP layer and then retrieving the listen port. However WebServer throws "Invalid port" when trying to pass in 0 as the port. There also doesn't appear to be a function to retrieve the port from WebServer.

rdeago commented 3 years ago

Hello @gyorokpeter, thanks for using EmbedIO!

Setting 0 as a port number is already being discussed in #506. I'm therefore closing this issue as duplicate.

As for retrieving the actual port number, it sort of comes with the package: there's little to no sense in implementing it now, but it's an obvious requirement once setting port 0 is allowed.