Re: [patch] IO::Socket::INET Broadcast patch
authorMax Baker <max@warped.org>
Fri, 8 Mar 2002 10:56:19 +0000 (02:56 -0800)
committerAbhijit Menon-Sen <ams@wiw.org>
Mon, 11 Mar 2002 03:06:59 +0000 (03:06 +0000)
   Message-Id: <20020308105619.A15039@warped.org>

p4raw-id: //depot/perl@15153

ext/IO/lib/IO/Socket/INET.pm

index 83efd09..f59c810 100644 (file)
@@ -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<IO::Socket::INET> 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