From a2cb6a2d5e1d91704eff9f5cebe73b773c708bc6 Mon Sep 17 00:00:00 2001 From: Martin Peach Date: Wed, 5 Nov 2008 19:06:23 +0000 Subject: Added broadcast permission to sockets as suggested by zmoelnig's patch 2221504 svn path=/trunk/externals/mrpeach/; revision=10361 --- net/udpsend.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'net/udpsend.c') diff --git a/net/udpsend.c b/net/udpsend.c index 6a6aef5..5234fd4 100644 --- a/net/udpsend.c +++ b/net/udpsend.c @@ -50,6 +50,7 @@ static void udpsend_connect(t_udpsend *x, t_symbol *hostname, struct hostent *hp; int sockfd; int portno = fportno; + int broadcast = 1;/* nonzero is true */ if (x->x_fd >= 0) { @@ -67,6 +68,15 @@ static void udpsend_connect(t_udpsend *x, t_symbol *hostname, sys_sockerror("udpsend: socket"); return; } +/* Based on zmoelnig's patch 2221504: +Enable sending of broadcast messages (if hostname is a broadcast address)*/ +#ifdef SO_BROADCAST + if( 0 != setsockopt(sockfd, SOL_SOCKET, SO_BROADCAST, (const void *)&broadcast, sizeof(broadcast))) + { + pd_error(x, "couldn't switch to broadcast mode"); + } +#endif /* SO_BROADCAST */ + /* connect socket using hostname provided in command line */ server.sin_family = AF_INET; hp = gethostbyname(hostname->s_name); -- cgit v1.2.1