gpsd-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [gpsd-dev] regression test puzling non-failure which should probably


From: Eric S. Raymond
Subject: Re: [gpsd-dev] regression test puzling non-failure which should probably fail
Date: Sat, 31 Jan 2015 13:28:27 -0500
User-agent: Mutt/1.5.23 (2014-03-12)

Hal Murray <address@hidden>:
> 
> address@hidden said:
> >> Isn't there a way of asking the system to pick an unused port
> >> number and then getting it to tell you the one it assigned?
> 
> > If there is, I don't know of it. 
> 
> If you specify a port number of 0, it assigns one for you.
> 
> >From the man page for bind:
>        EADDRINUSE
>               (Internet domain sockets) The port number was specified as  zero
>               in the socket address structure, but, upon attempting to bind to
>               an ephemeral port, it was determined that all  port  numbers  in
>               the  ephemeral port range are currently in use.  See the 
> discus‐
>               sion of /proc/sys/net/ipv4/ip_local_port_range ip(7).
> 
> >From the man page for ip:
>        When listen(2) is called on an
>        unbound socket, the socket is automatically bound to a random free port
>        with the local address set to INADDR_ANY.
> 
> I think getsockname can be used to retrieve the local address.
> 
> -------
> 
> >From the NetBSD man page for getsockname:
> 
>      Common uses of this function are as follows:
> 
>      o   When bind(2) is called with a port number of 0 (indicating the kernel
>          should pick an ephemeral port) getsockname() is used to retrieve the
>          kernel-assigned port number.

Thanks.  Remains to be seen how to use this in a Python context.
-- 
                <a href="http://www.catb.org/~esr/";>Eric S. Raymond</a>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]