Broadcast socket bind on Windows; '<broadcast>' or ''
Irmen de Jong
irmen at -NOSPAM-REMOVE-THIS-xs4all.nl
Sun Feb 16 06:50:01 EST 2003
Jp Calderone wrote:
> On Sat, Feb 15, 2003 at 11:47:40PM -0500, Jp Calderone wrote:
>
>> Binding to <broadcast> is the same as binding to '255.255.255.255' on
>>Linux, while binding to '' is the same as binding to '0.0.0.0' (in some
>>systems, there is no difference between these two addresses). The string
>>"<broadcast>" is not part of any kind of standard, though. Your best bet is
>>to bind to '255.255.255.255', then use setsockopt() to enable SO_BROADCAST.
>>
>
>
> Ahh, I should have looked at the Python docs :P "<broadcast>" is in fact
> defined by Python to be the same as INADDR_BROADCAST. So I too am curious
> why it does not work on Windows.
Exactly ;-)
But I tried your suggestion anyway, binding to 255.255.255.255.
Didn't work, same error as binding to '<broadcast>'.
So what I'm doing now is testing if the os is windows, and
use '' in that case, otherwise I use '<broadcast>'.
I will try to hack together a quick C program that calls
the bsd (actually winsock) API directly and see what that
does with different bind addresses under windows.
Irmen
More information about the Python-list
mailing list