source: trunk/listen.php@ 11

Last change on this file since 11 was 9, checked in by gegorbet, 10 years ago

fix to handle ~us3/bin on different hosts

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