Re: [tkined] problem: udp send broadcast

From: Erik Schoenfelder (schoenfr@gaertner.de)
Date: Fri Apr 21 2000 - 18:05:08 MET DST


Hi,

Dmitry> I it is necessary to send broadcast message on 67 ports As
Dmitry> this do? Say that not correctly?

Dmitry> but writes mistake:
Dmitry> udp send to host "255.255.255.255" port "67" failed: permission denied
Dmitry> while executing
Dmitry> "udp send $broadcast 255.255.255.255 67 $msg"
Dmitry> (file "dhcp" line 48)

well, some operating systmems do this per default (eg. solaris 2.5)
and some not (eg. linux).

if you are running linux adding SO_BROADCAST will help:

> SO_BROADCAST
> Set or get the broadcast flag. When enabled, data-
> gram sockets receive packets sent to a broadcast
> address and they are allowed to send packets to a
> broadcast address. This option has no effect on
> stream-oriented sockets.

this appended patch should do this:

--- tnmUdp.c-x Fri Apr 21 18:00:41 2000
+++ tnmUdp.c Fri Apr 21 18:03:25 2000
@@ -174,6 +174,17 @@
         return TCL_ERROR;
     }
 
+#ifdef SO_BROADCAST
+ /*
+ * Allow broadcast packets to be sent and received:
+ */
+ {
+ int one = 1;
+ setsockopt(sock, SOL_SOCKET, SO_BROADCAST,
+ (char *) &one, sizeof(one));
+ }
+#endif
+
     code = TnmSocketBind(sock, (struct sockaddr *) &name, sizeof(name));
     if (code == TNM_SOCKET_ERROR) {
         Tcl_AppendResult(interp, "can not bind socket on port \"", port,

i hope this helps,
                                                        Erik

--
!! This message is brought to you via the `tkined & scotty' mailing list.
!! Please do not reply to this message to unsubscribe. To subscribe or
!! unsubscribe, send a mail message to <tkined-request@ibr.cs.tu-bs.de>.
!! See http://wwwsnmp.cs.utwente.nl/~schoenw/scotty/ for more information.



This archive was generated by hypermail 2b29 : Mon Jan 08 2001 - 15:27:42 MET