Re: [PHP4BETA] Binary for UDP?

From: Date: Thu, 02 Mar 2000 15:46:29 +0000
Subject: Re: [PHP4BETA] Binary for UDP?
References: 1  Groups: php.version4 
Request: Send a blank email to php-version4+get-11348@lists.php.net to get a copy of this message
At 11:57 2-3-2000 -0500, Ian Redden wrote:
PHP Example w/ fread(): <?php $maxlen = 1024; $default_host = "171.64.75.234"; $default_port = "28001"; $connection = fsockopen("udp://".$default_host, $default_port, &$errno, &$errstr, 5); echo "Please wait... Retrieving Info...<br>\n"; if(!$connection) {
        echo "$errstr ($errno)<br>\n";
} else {
        $msgsend = "bah";
        fputs($connection, $msgsend);
        $msgrecv = fread($connection, $maxlen);
} echo $msgrecv; fclose($connection); ?> Result: Netscape hangs on CONNECT: Host www.whatever.com contacted. Waiting for reply... and never seems to even receive the header. This is strange because it should atleast print in the browser... "Please wait... Retrieving Info..."
It prints that only if 1 the page is ready 2 the buffer is full 3 flush is used so i suggest you do: echo "Please wait... Retrieving Info...<br>\n"; flush(); Greetz, Wico
Ian. On Thu, 2 Mar 2000, Andrei Zmievski wrote: 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. * -- PHP 4.0 Beta Mailing List <http://www.php.net/version4/> To unsubscribe, e-mail: php4beta-unsubscribe@lists.php.net For additional commands, e-mail: php4beta-help@lists.php.net To contact the list administrators, e-mail: php4beta-admin@lists.php.net -- PHP 4.0 Beta Mailing List <http://www.php.net/version4/> To unsubscribe, e-mail: php4beta-unsubscribe@lists.php.net For additional commands, e-mail: php4beta-help@lists.php.net To contact the list administrators, e-mail: php4beta-admin@lists.php.net


« previous php.version4 (#11348) next »