|
Boost Users : |
Subject: Re: [Boost-users] [Asio] How can you detect port collsions?
From: Martin Dyring-Andersen (mda_at_[hidden])
Date: 2009-07-24 06:03:07
> I am allocating port numbers on tcp connections dynamically, and must allocate
> and reserve the port number without blocking. I also have multiple instances of
> the process which needs to do this, and I'm plagued by port collisions.
>
> How do I detect, and avoid, port number collsions?
This is not ASIO, specific but hopefully it is possible using ASIO:
1) bind() socket to port 0. The IP stack should now assign a free port to the socket.
2) obtain the assigned port number using getsockname().
3) listen() / profit. :-)
Best regards,
Martin Dyring-Andersen
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net