Code: Select all
<?php
set_time_limit (0);
$address = '212.72.100.21';
$port = 9000;
$sock = socket_create(AF_INET, SOCK_STREAM, 0);
socket_bind($sock, $address, $port) or die('Could not bind to address');
socket_listen($sock);
$client = socket_accept($sock);
$input = socket_read($client, 1024);
$output = ereg_replace("[ \t\n\r]","",$input).chr(0);
socket_write($client, $output);
socket_close($client);
socket_close($sock);
?>also how can i test it is a socket is connectable? ie if my host doesn`t have some kind of firewalling service set that blocks it.
any help appreciated