Some great articles for sockets...might help out...
http://www.phpbeginner.com/columns/demitrious/sockets
http://www.phpbeginner.com/columns/demitrious/sockets-connection
B i g D o g
----- Original Message -----
From: "Josh Levine" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, June 26, 2002 11:32 AM
Subject: [PHP] PHP sockets/daemon problem
> 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
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php