Closed nechaido closed 7 years ago
Why do we need random ports? And for what reason? (maybe you propose it for tests) Good ways to do that:
@metarhia/jstp-core
@tshemsedinov Yes it's to be used in tests, at least for now (see https://github.com/metarhia/jstp/pull/183).
And this may indeed be prone to race conditions but I do not think we'll be able to see it in this project as it requires some real lot amount of simultaneous network tests to be run. But to avoid them completely this should probably be some sort of separate service which will keep track of pending requests.
@tshemsedinov mainly for tests, yeah, but there may be different use cases.
FWIW, we do support random ports; this issue is a bit confusing. We need an API to get a port a server is bound to, and it has nothing to do with random ports per se.
@lundibundi bind(0)
is not prone to race conditions, using hardcoded ports is ;)
@aqrln I meant in case of implementing something different than using bind(0) =).
@aqrln ok, it's clear after renaming
We need an API to get a random free port. At the moment I have two ways to write test:
0
port, and get server port by accessing the rawServerBoth are not ok. It would be great to be able to get a random free port. Although, this feature may be prone to race condition.