source: trunk/listen.php@ 1

Last change on this file since 1 was 1, checked in by zollarsd, 12 years ago

Initial import

File size: 657 bytes
Line 
1<?php
2
3include "/home/us3/bin/listen-config.php";
4
5$socket = socket_create( AF_INET, SOCK_DGRAM, SOL_UDP );
6
7// Listen on all interfaces
8if ( ! socket_bind( $socket, 0, $listen_port ) )
9{
10 $msg = "listen bind failed: " . socket_strerror( socket_last_error( $socket ) );
11 write_log( "$self: $msg" );
12 exit();
13};
14
15$handle = fopen( $pipe, "r+" );
16
17$php = "/usr/bin/php";
18
19$cmd = "nohup $php $home/bin/manage-us3-pipe.php >>$home/etc/manage.log 2>&1 </dev/null &";
20
21exec( $cmd );
22
23do
24{
25 socket_recvfrom( $socket, $buf, 200, 0, $from, $port );
26 fwrite( $handle, $buf . chr( 0 ) );
27
28} while ( trim( $buf ) != "Stop listen" );
29
30socket_close( $socket );
31?>
Note: See TracBrowser for help on using the repository browser.