Skip to content
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

Question: Can sf::TcpListener pick a random available port? #1657

Closed
Unarelith opened this issue May 10, 2020 · 2 comments
Closed

Question: Can sf::TcpListener pick a random available port? #1657

Unarelith opened this issue May 10, 2020 · 2 comments

Comments

@Unarelith
Copy link
Contributor

Subject

sf::UdpSocket is capable of selecting a random available port as described in the documentation, using sf::UdpSocket::bind(sf::Socket::AnyPort):

You can use the special value Socket::AnyPort to tell the system to automatically pick an available port, and then call getLocalPort to retrieve the chosen port.

But there is nothing about sf::TcpListener::listen(sf::Socket::AnyPort).

I tried on my ArchLinux. It works as expected, and I can use sf::TcpListener::getLocalPort to know which port it decided to pick.

Is the documentation missing, or is it unsupported/not portable/something else?

Your environment

  • ArchLinux
  • SFML 2.5
@LaurentGomila
Copy link
Member

I'd say the documentation is missing. Internally, TcpListener::listen uses the same call to ::bind as sf::UdpSocket, so it should work the same.

@Unarelith
Copy link
Contributor Author

I just opened #1658 to add documentation on that topic, closing this ticket.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
SFML 2.6.0
  
Done
Development

No branches or pull requests

3 participants