asio newbie: picking a free port number

23 Feb
2010
23 Feb
'10
1:15 p.m.
I am writing a simple client/server program which will only run on Unix boxes (linux, HP-UX, AIX). By manually choosing the port number,everything works ok. Whenever I get an "Address in use" i choose a different number. I want to free clients of this program from having to do this.
From googling around it appears that there is way of the OS, to pick a free port number. i.e by binding to port 0, sock.bind(('', 0))/ sock.getsockname()[1]
Is there any boost:asio recommended way of doing this ? Is there any way of completely abstracting out the use of port numbers from an end users perspective using boost asio ? i.e so that client/server agree on a free port number behind the scenes. Any help appreciated. Best regards, Ta, Avi
5480
Age (days ago)
5480
Last active (days ago)
1 comments
2 participants
participants (2)
-
Avi Bahra
-
Rutger ter Borg