Most recent edit on 2007-08-01 16:03:39 by JimLucas
Additions:
$address = '66.39.167.51';
Deletions:
$address = '66.';
Oldest known version of this page was edited on 2007-08-01 16:03:24 by JimLucas []
Page view:
#!/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.';
$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;
}
}