/[meteor]/googlecode.com/svn/trunk/meteorBroadcast
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /googlecode.com/svn/trunk/meteorBroadcast

Parent Directory Parent Directory | Revision Log Revision Log


Revision 48 - (show annotations)
Mon Feb 4 22:23:52 2008 UTC (11 years, 5 months ago) by knops.gerd
File size: 2743 byte(s)
• Added simple UDP broadcast abilities

1 #!/usr/bin/perl -w
2 ###############################################################################
3 # Meteor
4 # An HTTP server for the 2.0 web
5 # Copyright (c) 2006 contributing authors
6 #
7 # meteor broadcast
8 #
9 # A very simple program to broadcast one or more strings to meteor servers.
10 # Call as:
11 #
12 # meteorBroadcast <port> 'A string' ...
13 #
14 # See meteor documentation how to enable UDP support and what strings
15 # are accepted.
16 #
17 ###############################################################################
18 #
19 # This program is free software; you can redistribute it and/or modify it
20 # under the terms of the GNU General Public License as published by the Free
21 # Software Foundation; either version 2 of the License, or (at your option)
22 # any later version.
23 #
24 # This program is distributed in the hope that it will be useful, but WITHOUT
25 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
26 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
27 # more details.
28 #
29 # You should have received a copy of the GNU General Public License along
30 # with this program; if not, write to the Free Software Foundation, Inc.,
31 # 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
32 #
33 # For more information visit www.meteorserver.org
34 #
35 ###############################################################################
36
37 ###############################################################################
38 # meterod version
39 ################################################################################
40
41 $::VERSION='0.01.00';
42
43 our $DEBUG=1;
44
45 ###############################################################################
46 # Configuration
47 ###############################################################################
48
49 use strict;
50 use Socket;
51
52 ###############################################################################
53 # Main
54 ###############################################################################
55
56 unless(scalar(@ARGV>=2) && $ARGV[0]=~/^\d+$/)
57 {
58 die("Usage:\n\n\t$0 <port> <string> ...\n\n");
59 }
60
61 my $port=shift;
62
63 # Open udp broadcast
64 socket(UDP,PF_INET,SOCK_DGRAM,getprotobyname('udp'))
65 || die("socket: $!");
66 setsockopt(UDP,SOL_SOCKET,SO_BROADCAST,1);
67 select((select(UDP),$|=1)[0]);
68 our $UDP_BC=sockaddr_in($port,INADDR_BROADCAST);
69
70 # if(defined($LOCAL_IP))
71 # {
72 # my $local=sockaddr_in(0,inet_aton($LOCAL_IP))
73 # || die("$class: local host '$LOCAL_IP' invalid");
74 #
75 # bind(UDP,$local) || die("$class bind: $!");
76 # }
77
78 foreach my $data (@ARGV)
79 {
80 send(UDP,$data,0,$UDP_BC) or die("send: $!");
81 print "Sent ",length($data)," bytes\n" if($DEBUG);
82 }
83
84 1;
85 ############################################################################EOF

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26