Re: broadcast to 255.255.255.255
Re: broadcast to 255.255.255.255
- Subject: Re: broadcast to 255.255.255.255
- From: Justin Walker <email@hidden>
- Date: Thu, 3 Apr 2003 09:14:30 -0800
On Thursday, Apr 3, 2003, at 00:46 US/Pacific, Satoshi Hirata wrote:
Hi
I'm developing a application stacked on TCP/UDP using
OpenTrasPort/Socket.
I want to broadcast to 255.255.255.255, but it is sent to subnet
address
(ex. 172.16.127.255) automatically in MacOSX.
Is it possible "real" broadcast (255.255.255.255) in MacOSX?
Of course it is; a number of functions would not work correctly without
this ability. You do need to "condition" the underlying socket for
your OT endpoint for broadcast ability:
setsockopt(sockfd, SOL_SOCKET, SO_BROADCAST, &on, sizeof(on));
The constants are defined in <sys/socket.h>, and in this call, 'on' is
an "int" whose value is 1 (enable) or 0 (disable).
Note that, without the socket option enabled, you will see the behavior
you describe: the datagram is sent to the subnet broadcast address.
Moreover, without some laborious effort, the datagram is only sent on
the "primary" subnet. If you want this datagram to be sent on multiple
subnets, via multiple interfaces, I believe you will have to resort to
BPF or libnet.
Regards,
Justin
--
Justin C. Walker, Curmudgeon-At-Large *
Institute for General Semantics | If you're not confused,
| You're not paying attention
*--------------------------------------*-------------------------------*
_______________________________________________
macnetworkprog mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/macnetworkprog
Do not post admin requests to the list. They will be ignored.