Re: [PHP4BETA] Binary for UDP?
| From: | Ian Redden | Date: | Thu, 02 Mar 2000 17:00:01 +0000 |
| Subject: | Re: [PHP4BETA] Binary for UDP? | ||
| References: | 1 | Groups: | php.version4 |
| Request: | Send a blank email to php-version4+get-11347@lists.php.net to get a copy of this message | ||
Further note. Using fread() and checking with
lynx -source http://www.myserver.com/example.php` returns
absolutely
nothing in the console.
On Thu, 2 Mar 2000, 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..."
>
> 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
>