New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
random port #126
Comments
Hi! Thanks for reporting this use-case. We've never used RESTinio in such scenarios. I'll investigate the behavior of RESTinio's acceptor and reply to you back later. |
At this time I don't see an easy way to pass the actual local_endpoint of the acceptor to the outside of One of the current ideas is to add another callback to asio::ip::tcp::endpoint server_endpoint;
...
server_t srv1{
restinio::external_io_context(*context),
settings_t{}.port(0).address("localhost")
.post_acceptor_bind_hook([&server_endpoint](asio::ip::tcp::acceptor & acceptor) {
server_endpoint = acceptor.local_endpoint();
})
.request_handler([](auto) {
return restinio::request_accepted();
})};
... But I'm not sure that's a good idea yet. Will think further. |
I don't know this library well enough, nor its design. hoooowever some ideas 😆
|
acceptor_post_bind_hook is introduced.
Hi @qwertzui11 ! A new post-bind callback is added to RESTinio. You can see an example of its usage here: restinio/dev/test/handle_requests/acceptor_post_bind_hook/main.cpp Lines 23 to 66 in f3bdbfc
The new functionality is in 0.6-dev-0.6.11 branch now. I plan to add yet more functionality into v.0.6.11 before the public release of that version. Hope I can complete it in a week, but it hard to predict. So if you can't wait please let us know. |
excellent. I'll wait and try it out as soon as it's available on conan. Thx for the great work! 😍 |
It seems that the scope of v.0.6.11 is completed. We have to update to docs and then the release will be published. |
works! awesome, thx! |
hi. Thx for your great on this awesome framework.
I'd like to host the server on a random port. Aka using port
0
and then call some method likeget_port()
.asio::*::acceptor
assigns on port 0 a random port.This is useful when it comes to unittests, that may run in parallel.
I could not find any information on that topic. Is there a possibility to set the port to 0 and then retreive it?
so far I got:
thx for ur time!
The text was updated successfully, but these errors were encountered: