Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 5

Qt-interest Archive, April 2008
Getting the UDP port dynamically


Message 1 in thread

Hi,

Is there a way to get the UDP port (to bind to) dynamically from the OS
(using QUdpSocket or elsewise). This way I can make sure that my application
is not using a port already used by any other application.

I am using QT 4.3 (on both Win and Linux)

Thanks,
Andy

Message 2 in thread

Andy Gynn wrote:
>Hi,
>
>Is there a way to get the UDP port (to bind to) dynamically from the OS
>(using QUdpSocket or elsewise). This way I can make sure that my
> application is not using a port already used by any other application.

Tell it to bind to port 0. The port number will be allocated automatically 
by the OS.

-- 
 [ signature omitted ] 

Attachment: signature.asc
Description: This is a digitally signed message part.


Message 3 in thread

Thx. It works!!

On Thu, Apr 24, 2008 at 4:49 PM, Thiago Macieira <
thiago.macieira@xxxxxxxxxxxxx> wrote:

> Andy Gynn wrote:
> >Hi,
> >
> >Is there a way to get the UDP port (to bind to) dynamically from the OS
> >(using QUdpSocket or elsewise). This way I can make sure that my
> > application is not using a port already used by any other application.
>
> Tell it to bind to port 0. The port number will be allocated automatically
> by the OS.
>
> --
> Thiago José Macieira - thiago.macieira AT trolltech.com
> Trolltech ASA - Sandakerveien 116, NO-0402 Oslo, Norway
>