feof , http and hanging...

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
bucz
Forum Newbie
Posts: 6
Joined: Mon Aug 03, 2009 2:49 am

feof , http and hanging...

Post by bucz »

hello,

I tried to connect to a http server (google. for example) using sockets. i have opened socked, got a full reply from the server and... my code is dead-looping. It does not recognize EOF i think. I have read that there are some issues with EOF, I have tried different thinks and nothing... any ideas?

for example this is dead-looping:

Code: Select all

 
        $cur = fgets($fp,1024);
        while(!feof($fp)){
            echo $cur;
            $cur = fgets($fp,1024);
        }
 
dejvos
Forum Contributor
Posts: 122
Joined: Tue Mar 10, 2009 8:40 am

Re: feof , http and hanging...

Post by dejvos »

Why you don't use some PEAR library .... http://pear.php.net/search.php?q=HTTP_R ... es&x=0&y=0

I'm not sure if it works throught your way.
User avatar
jackpf
DevNet Resident
Posts: 2119
Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK

Re: feof , http and hanging...

Post by jackpf »

Or you could just use cURL :)
bucz
Forum Newbie
Posts: 6
Joined: Mon Aug 03, 2009 2:49 am

Re: feof , http and hanging...

Post by bucz »

can i use all that tools when i am NOT working on my own server? could they be installed locally somehow?
User avatar
jackpf
DevNet Resident
Posts: 2119
Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK

Re: feof , http and hanging...

Post by jackpf »

Yes. Do you have apache & php installed?
bucz
Forum Newbie
Posts: 6
Joined: Mon Aug 03, 2009 2:49 am

Re: feof , http and hanging...

Post by bucz »

yup, apache and php are on the board
User avatar
jackpf
DevNet Resident
Posts: 2119
Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK

Re: feof , http and hanging...

Post by jackpf »

Then you need to download the relevant dll or so (depending on your OS), and put a line (or uncomment it if it already exists) in php.ini with something like:

[PHP_EXTENSION]
extension=extension.dll

But replacing extension with the extension.
bucz
Forum Newbie
Posts: 6
Joined: Mon Aug 03, 2009 2:49 am

Re: feof , http and hanging...

Post by bucz »

and DLL is a 'real windows dll' or it shall also go with linux?
User avatar
jackpf
DevNet Resident
Posts: 2119
Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK

Re: feof , http and hanging...

Post by jackpf »

You'll need a .so file for linux.
Post Reply