From: Max Baker Date: Fri, 8 Mar 2002 10:56:19 +0000 (-0800) Subject: Re: [patch] IO::Socket::INET Broadcast patch X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=3e3f5e61dbaf80be7bb6393d494e3662496818b6;p=p5sagit%2Fp5-mst-13.2.git Re: [patch] IO::Socket::INET Broadcast patch Message-Id: <20020308105619.A15039@warped.org> p4raw-id: //depot/perl@15153 --- diff --git a/ext/IO/lib/IO/Socket/INET.pm b/ext/IO/lib/IO/Socket/INET.pm index 83efd09..f59c810 100644 --- a/ext/IO/lib/IO/Socket/INET.pm +++ b/ext/IO/lib/IO/Socket/INET.pm @@ -159,6 +159,11 @@ sub configure { return _error($sock, $!, "$!"); } + if ($arg->{Broadcast}) { + $sock->sockopt(SO_BROADCAST,1) or + return _error($sock, $!, "$!"); + } + if($lport || ($laddr ne INADDR_ANY) || exists $arg->{Listen}) { $sock->bind($lport || 0, $laddr) or return _error($sock, $!, "$!"); @@ -309,6 +314,7 @@ C provides. ReuseAddr Set SO_REUSEADDR before binding Reuse Set SO_REUSEADDR before binding (deprecated, prefer ReuseAddr) ReusePort Set SO_REUSEPORT before binding + Broadcast Set SO_BROADCAST before binding Timeout Timeout value for various operations MultiHomed Try all adresses for multi-homed hosts Blocking Determine if connection will be blocking mode @@ -355,6 +361,12 @@ Examples: $sock = IO::Socket::INET->new('127.0.0.1:25'); + $sock = IO::Socket::INET->new(PeerPort => 9999, + PeerAddr => inet_ntoa(INADDR_BROADCAST), + Proto => udp, + LocalAddr => 'localhost', + Broadcast => 1 ) + or die "Can't bind : $@\n"; NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE