apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joe Orton <jor...@redhat.com>
Subject Re: [PATCH] we need to init _unknown?
Date Tue, 28 Nov 2006 09:59:34 GMT
On Mon, Nov 27, 2006 at 01:36:53PM -0600, William Rowe wrote:
> Joe Orton wrote:
> > 
> > If the socket is bound to then the local address of the socket 
> > *is* known to be  There is no need to call getsockname() to 
> > confirm that later, it can't change until _connect() is called, at which 
> > point the existing code does already DTRT by setting the "unknown" flag 
> > iff necessary.
> How does that differ from the port being 0 == unknown in bind?
> Port 0 is ephemeral.  IP is ephemeral.  I'm just not groking this
> design pattern (using the word design somewhat losely :)  Why is the
> port_unknown set here then?

Because this exactly reflects the semantics of bind().

When you bind() to the address the socket is bound to really is  getsockname() will tell you nothing different about the 
address.  When you bind to port 0 the kernel will pick a random local 
port instead, and you have to call getsockname() if you want to find out 
what port the socket is actually bound to.


View raw message