Sending a broadcast message using raw sockets

Rob Williscroft rtw at rtw.me.uk
Tue Jan 22 04:06:20 EST 2013


Peter Steele wrote in
news:0c2b3482-df46-4324-8bf9-2c45d3f6b516 at googlegroups.com in
comp.lang.python: 

> On Monday, January 21, 2013 1:10:06 AM UTC-8, Rob Williscroft wrote:
>> Peter Steele wrote in
>> 
>> news:f37ccb35-8439-42cd-a063-962249b44903 at googlegroups.com in
>> 
>> comp.lang.python: 
>> 
>> > I want to write a program in Python that sends a broadcast message

[snip]

>> This is part of my Wake-On-Lan script:
>> 
>> def WOL_by_mac( mac, ip = '<broadcast>', port = 9 ):
 
[snip]
 
> Thanks for the code sample. Does this code work if the box has no IP
> or default route assigned? I'm away from the office at the moment so I
> can't test this. 

No idea, but the sockets system must be up and running before the 
card (interface) has an IP (otherwise how would it ever get assigned) 
and I presume DHCP works in a similar manner.
 
However the "route assignemt" is irrelevent, broadcast messages never 
get routed.

Rob
-- 




More information about the Python-list mailing list