You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Feature: OS-chosen port available to application #703
Use case: I want to let the OS choose the port by supplying port 0 during initialization. This allows multiple applications to run concurrently, and the actual port will be communicated e.g. through zeroconf to the user.
I need to know the port chosen from the application, e.g., by having an API on the server to query the used address and port.
I think it's worth being able to access the IP address and port used by the system and make it available to the user. I have a problem with returning strings though, as it may be better to return a copy of the address and the actual port values directly.
I like the idea of exposing this from the server's API, and passing in options that help decide whether/how to initialise the server. For example, there are ways of specifying the port and address to listen to through the server's options type. It should be feasible to provide the IP address you'd want, and a 0 for the port. I suppose you're already doing that and would like a way in pulling it out.
I saw your pull request before seeing this post.
Thanks again, and I'd like to see an updated PR with these comments addressed.
I allow myself to comment on this, since I am interested in this feature as well. I think returning strings is ok because the internal data type is string already, so no conversion/copy is required in the getter functions. Returning another data type should incorporate changing the internal storage type as well. @elie, could you apply the changes to async_server as well?
Activity
deanberris commentedon Nov 14, 2016
Hi @eile -- I'm so sorry I just saw this.
I think it's worth being able to access the IP address and port used by the system and make it available to the user. I have a problem with returning strings though, as it may be better to return a copy of the address and the actual port values directly.
I like the idea of exposing this from the server's API, and passing in options that help decide whether/how to initialise the server. For example, there are ways of specifying the port and address to listen to through the server's options type. It should be feasible to provide the IP address you'd want, and a 0 for the port. I suppose you're already doing that and would like a way in pulling it out.
I saw your pull request before seeing this post.
Thanks again, and I'd like to see an updated PR with these comments addressed.
Cheers
umennel commentedon Jan 30, 2017
I allow myself to comment on this, since I am interested in this feature as well. I think returning strings is ok because the internal data type is string already, so no conversion/copy is required in the getter functions. Returning another data type should incorporate changing the internal storage type as well.
@elie, could you apply the changes to async_server as well?
dnachbaur commentedon Feb 1, 2017
See updated PR: #729