Boost: how do we specify "any port" for a TCP server?

  • How can I specify "select any available port" for a TCP based server in Boost?
  • How to restore the port after connecting?

UPDATED: by "available port" I mean: the OS can select any available port, that is, I do not want to specify the port.

+4
source share
1 answer

Question 1: Use port number 0

Question 2: Use acceptor.local_endpoint().port()

+7
source

All Articles