Martin Pirker
10/23/2004 6:50:00 PM
Joel VanderWerf <vjoel@path.berkeley.edu> wrote:
> Eric Hodel wrote:
>> On Oct 22, 2004, at 9:34 PM, Joel VanderWerf wrote:
>>> Martin Pirker wrote:
>>>> Copying the minimalistic UDP receive example from the online Pickaxe I
>>>> require 'socket'
>>>> port = 12000
>>>> server = UDPSocket.open
>>>> server.bind(nil, port)
>>> ^^^
>>> Try a hostname here? You can use the string '<any>'. I guess that
>>> means any interface.
>>
>> No. nil means bind to all interfaces. See getaddrinfo(3).
>
> Ok, but UDPSocket#bind accepts '<any>' as well. It appears (from brief
> groping in etx/socket/socket.c) that nil and '<any>' are synonyms. So
> substituting one for the other will not make a difference in the problem
> the OP was trying to fix.
but it does fix it
nil gives a "UDP localhost:12000" binding according to lsof
"<any>" and "" gives a "UDP *:12000" binding and appears to work as
expected => accepts any packet arriving from any sender at this port
question is, why I didn't find this myself?
I assumed nothing set aka nil means "don't bind to anything, accept
everything", so I just copied from the example
reading the "socket-level access" paragraph at the beginning points
one to "" as INADDR_ANY, but nowhere a word of "<any>" or a definiton
of nil ?
thanks! always nice&helpful ppl here,
Martin