Hi, first post, but I have a socket question.
I have written this PHP script and am executing it through a .bat file.
#!/user/local/bin/php -q
<?php
set_time_limit(0);
$address = '127.0.0.1';
$port = 9000;
$sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
socket_bind($sock, $address, $port) or die('could not bind to address');
socket_listen($sock, 5);
$client = socket_accept($sock);
socket_write($client, "Welcome fo-shizzles!
\r");
$input = socket_read($client, 1024, PHP_BINARY_READ);
$output = "Welcome to my PHP socket server. You sent me: $input
\r";
socket_write($client, $output);
socket_close($client);
socket_close($sock);
?>
When I run & connect, it is fine, yet it returns the answer message & closes the connection when I type the first response character (no matter what it is)
What can I do?