#!/usr/local/bin/php –q
<?php
// Set time limit to indefinite execution
set_time_limit (0);
// Set the ip and port we will listen on
$address =
'66.39.167.51';
$port =
28000;
# If it dies, restart it!
while ( true ) {
// Create a TCP Stream socket
if ( $sock =
socket_create(AF_INET, SOCK_DGRAM, SOL_UDP
) ) {
// Bind the socket to an address/port
if ( socket_bind($sock,
$address,
$port) ) {
// Start listening for connections
socket_listen($sock);
/* Accept incoming requests and handle them as child processes */
$client =
socket_accept($sock);
// Read the input from the client – 1024 bytes
$input =
socket_read($client,
1024);
} else {
echo "Could not bind to address.\n";
break;
}
// Close the master sockets
socket_close($sock);
} else {
echo "Could not create socket connection.\n";
break;
}
}
There are no comments on this page. [Add comment]