Original Post
Hi there. I have a service daemon running which listens for TCP/IP connections. It receives text commands and writes out text replies very quickly. My PHP script uses it like this:
$socket = socket_create (AF_INET6, SOCK_STREAM, SOL_TCP);
if (!$socket || !socket_connect ($socket, $address, $port))
return "";
echo "About to write.\n";
socket_write ($socket, $command, strlen($command));
echo "Written\n";
$p = socket_read ($socket, 100);
The connection is made immediately (the first echo executes) but there is a sometimes a long pause before the second echo. I understand that TCP/IP makes no guarantees on delivery time, and has no conecpt of a flush, but that doesn't explain why the function takes so long to return. Upwards of 20 seconds very often, and at the moment it's connecting to localhost. Any thoughts on why this might be happening? I'm certain the problem isn't at the daemon end. Thanks and Merry Christmas!