Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Provide a way to access acceptor::local_endpoint #458

Closed
zaphoyd opened this issue Aug 20, 2015 · 4 comments
Closed

Provide a way to access acceptor::local_endpoint #458

zaphoyd opened this issue Aug 20, 2015 · 4 comments

Comments

@zaphoyd
Copy link
Owner

zaphoyd commented Aug 20, 2015

Example use case: When I start a server on port 0 the OS picks a free port for me as expected. However, there doesn't seem to be a way to find out which port it picked. This information is available in the asio acceptor but is not exposed in the endpoint. Would it be possible to expose it? The relevant method is acceptor::local_endpoint.

@ComicSansMS
Copy link

This would help us a lot in testing.

For automated tests, you really want the OS to pick the port so that you avoid having to fail if a hardcoded port happens to be taken. Currently this is not possible with websocketpp, as there is no way to determine afterwards how to connect to a server.

@hussain7
Copy link

Pullrequest " API to expose TCP port #472 " deals with the clean way of exposing acceptor::local endpoint 's port .It is a handy API to retrieve the ephemeral port set by the OS .The client process can then dynamically connect using this port. @zaphoyd Please review it and suggest if some further changes are required.

@zaphoyd
Copy link
Owner Author

zaphoyd commented Nov 5, 2015

I've pushed a patch to the develop branch that adds a get_local_endpoint method to Asio Transport endpoints. It can be used to retrieve information about the address and port the server is listening on.

@zaphoyd
Copy link
Owner Author

zaphoyd commented Feb 22, 2016

This feature was added. If any problems crop up in the future, go ahead and open a new issue.

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

3 participants