On 29/07/07, guy keren <[EMAIL PROTECTED]> wrote:
>
> i sent my mail before i saw yours, or i wouldn't have bothered ;)


I got my mail out later than you because I was busy writing a program to
test it.
And it's good you sent it so I know about this option (of binding to a
device) now.

the only question regarding what you found, is whether this is a
> supported feature, or a "bug", that might get "fixed" in a later version
> of the kernel.if it's a feture, it surely is simple enough to use. note
> that unlike you, i didn't test my method, so currently shachar has only
> one sure method - your method.


As far as I can tell from the kernel's source, that's the way it's supposed
to happen - binding to port 0 has always meant "I don't care, just get me a
free port number" and the code doesn't seem to care in its handling whether
this comes attached to "INADDR_ANY" or any other address. In fact, I can't
remember any documentation I read about this ever (even on 4.2BSD) that
suggested that port 0 requires only INADDR_ANY with it.

It looks right now like somehow people just assume that it's not supposed to
work (and I admit I needed the kernel source and the example program to
"prove that they don't have a sister", so to speak).

Just one thing I think I noticed from this program - netstat(8) might not
show your socket until you call listen(2) or connect(2). At least connect(2)
seems to have made the difference in my test program and I guess listen(2)
will do the same.

Cheers,

--Amos

Reply via email to