aboutsummaryrefslogtreecommitdiff
path: root/net
diff options
context:
space:
mode:
authorMartin Peach <mrpeach@users.sourceforge.net>2008-11-05 19:06:23 +0000
committerMartin Peach <mrpeach@users.sourceforge.net>2008-11-05 19:06:23 +0000
commita2cb6a2d5e1d91704eff9f5cebe73b773c708bc6 (patch)
tree4210804f23c852d15e5428359e8336d6d17cdd67 /net
parent8ee9cabbd4a624c6a97ef96b13a9d3ae8f706907 (diff)
Added broadcast permission to sockets as suggested by zmoelnig's patch 2221504
svn path=/trunk/externals/mrpeach/; revision=10361
Diffstat (limited to 'net')
-rw-r--r--net/udpsend.c10
1 files changed, 10 insertions, 0 deletions
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);