I'm trying to write a simple PHP script that communicates with a daemon
running on the same server.

Basically, the daemon just accepts an integer and returns an integer:

[josh@jlevine-research josh]$ telnet 127.0.0.1 60324
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
9
25Connection closed by foreign host.

When I try doing this with PHP, however, the output is 2[]5 (where [] ==
a small square symbol).

Here is the script:

<?php
$fp = fsockopen("127.0.0.1", 60324, $errno, $errstr);
if (!$fp) {
    echo "ERROR: $errno - $errstr<br>\n";
} else {
    socket_set_blocking ($fp, 1);
    socket_set_timeout($fp, 200);
    fwrite($fp,"9\n");
    $return = fread($fp,4);
    echo $return;
    fclose($fp);
}
?>

I've tried various string format and type-casting functions with no
results (usually just returns nothing after formatted).

Any ideas?

Thanks in advance,
Josh Levine

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to