Re: [PHP4BETA] Binary for UDP?
| From: | Andrei Zmievski | Date: | Thu, 02 Mar 2000 14:50:21 +0000 |
| Subject: | Re: [PHP4BETA] Binary for UDP? | ||
| References: | 1 2 | Groups: | php.version4 |
| Request: | Send a blank email to php-version4+get-11342@lists.php.net to get a copy of this message | ||
On Thu, 02 Mar 2000, Ian Redden wrote:
> Yes, it does work, however it is not "BINARY-SAFE".
>
> It should return binary info captured in a variable so I can plug that
> into unpack and read my info then display it on the screen however I like.
> I have already written a perl version and have it completed, unfortunately
> the website that will use it, absolutely refuses to use PERL. :(
>
> Thanks, Ian.
>
> Working Example:
> ----------------
>
> <?php
> $maxlen = 1024;
> $default_host = "171.64.75.234";
> $default_port = "28001";
> $connection = fsockopen("udp://".$default_host, $default_port, &$errno,
> &$errstr, 5);
>
> if(!$connection) {
> echo "$errstr ($errno)<br>\n";
> } else {
> $msgsend = "bah";
> fputs($connection, $msgsend);
> $msgrecv = fgets($connection, $maxlen);
> }
> fclose($connection);
> ?>
Why not use fread() instead?
-Andrei
* The best source is the source code. *