开发者

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

开发者 https://www.devze.com 2022-12-11 04:38 出处:网络
How can I specify \"pick any available port\" for a TCP based server in Boost? And how do I retrieve the port once a connection is accepted?
  1. How can I specify "pick any available port" for a TCP based server in Boost?
  2. And how do I retrieve the port once a connection is accepted?

UPDATED: By "available port" I mean: the OS can pick any available port i.e. I do not want to s开发者_C百科pecify a port.


Question 1: Use port number 0

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

0

精彩评论

暂无评论...
验证码 换一张
取 消