472,982 Members | 1,586 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,982 software developers and data experts.

UDP broadcast over a specific interface

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

Jul 19 '07 #1
1 11422
On Jul 19, 7:09 am, Jean-Paul Calderone <exar...@divmod.comwrote:
On Thu, 19 Jul 2007 12:32:02 -0000, "Larry.Mart...@gmail.com" <larry.mart...@gmail.comwrote:
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?

IP_MULTICAST_IF is for multicast UDP, which doesn't have anything to do
with broadcast UDP.

Try just doing this, instead:

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

You shouldn't need to mess with anything beyond that.
Thanks! This works perfectly.

-larry

Jul 19 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Lincoln Yeoh | last post by:
Hi, If I have a program listening on 0.0.0.0:(someport) on all interfaces, how do I know which network interface a broadcast packet is coming in on - assuming Linux and _many_ interfaces. And...
6
by: pekspro | last post by:
I need some code that gets the address from a server. I read somewhere that you could do this by starting some broadcast server using UDP. The client should send an broadcast message, and when the...
8
by: Frank Esser | last post by:
Hello! I have got machines that answer a certain UDP broadcast request with certain information about them. Some years ago I wrote a VB6 application that just sent out this UDP broadcast...
2
by: Gunnar_Frenzel | last post by:
Hello, this might be an easy question, but I don't have any handy solution at hand. I have an application that is supposed to send UDP broadcast. So far so easy, I did: Socket sockSendBroadcast...
12
by: Bob Jones | last post by:
I have an odd business requirement and I think that the implementation is not correct in the terms of OOP development. Any help on the concepts would be very appreciated! We currently have a...
19
by: dl | last post by:
I'll try to clarify the cryptic subject line. Let's say I have a base class 'GeometricObject' with a virtual method 'double distance (const GeometricObject &) const'. Among the derived classes...
2
by: Mali Findik | last post by:
Hi @ll, i've got problems with sending an UDP broadcast datagramm over two network interfaces. The code is like this: <Code> UdpClient client = new UdpClient(); IPEndPoint remoteEndPoint =...
0
by: riaancillie | last post by:
I apologize in advance since this isn't strictly the most appropriate group to ask this question in. I am using a Socket to broadcast UDP datagrams as such: FSocket.EnableBroadcast = true;...
4
by: Giovanni | last post by:
Hello community, I'm currently writing a broadcast sender class in C# .NET (using .NET Framework 3.5). On my computer there are more than one local network interface and if I send a broadcast,...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.