UDP broadcast over a specific interface

Larry.Martell at gmail.com Larry.Martell at gmail.com
Thu Jul 19 08:32:02 EDT 2007


I am trying to send UDP broadcast packets over a specific interface
and I
am having trouble specifying the interface:

host='192.168.28.255'
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.bind(('',0))
sock.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
sock.setsockopt(socket.IPPROTO_IP, socket.IP_MULTICAST_IF,
socket.inet_aton(host))

socket.error: (49, "Can't assign requested address")

What am I doing wrong? How can I force my broadcast packets to go out
a specific interface?

TIA!
-larry




More information about the Python-list mailing list