I have a server.php:
<?php
set_time_limit (0);
$host = '127.0.0.1';
$port = 1234;
$sock = socket_create(AF_INET, SOCK_STREAM, 0) or die("could not create socket");
socket_bind($sock, $host, $port) or die("Could not bind to socket\n");
socket_listen($sock, 3) or die("Could not set up socket listener\n");
while (true)
{
$spawn = socket_accept($sock) or die("Could not accept incoming connection\n");
$input = socket_recv($spawn, $c, 1024, MSG_WAITALL) or die("Could not read input\n");
socket_write($spawn, $input, strlen ($input)) or die("Could not write output\n");
}
?>
and a client.php has the following relevant code:
$localhost = "127.0.0.1";
$localport = 1234;
$msg = "hi";
$fp2 = socket_create(AF_INET, SOCK_STREAM, 0);
socket_connect($fp2, $localhost, $localport) or die("connect failed");
socket_send($fp2, $msg, 1024,0) or die("send failed");
I'm trying to get the server to receive the message "hi". Any help would be appreciated. Thanks in advanced.