Re: re:Timing out an fgets
| From: | jeremy brand | Date: | Fri, 18 Aug 2000 06:04:02 +0000 |
| Subject: | Re: re:Timing out an fgets | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-12414@lists.php.net to get a copy of this message | ||
> > $foo = "GET / HTTP/1.1\r\n\r\n";
> > fwrite($file_pointer, $foo, strlen($foo));
> >
> > Then, you should be able to receive data...
> > Otherwise, of course it is going to just hang...
>
> Thats correct my understanding is that what I have just written is a generic tcip interface, to
> cut a long story short I am writing a client interface to an Online Credit Card Verification
> server (OCV) so what I have sent it is just a standard ASCII string (a packet of information).
> Of course this string is very specific and has all sorts of requirements, this isn't my
> problem
> as the server is responding properly under normal circumstances.
>
> The OCV server then sends back an result, but in my case I am testing for an situation where a
> request has been sent, but for some unknown reason the server doesn't respond, it is upto
> me to
> recover from this condition, this is why I am trying to timeout the fgets as you said it will
> just hang, I thought the connection handling may be an easy way out but we will see....
>
> Thanks for the clarification I will try the above example now...
Another idea:
You may want to set your file pointer to non-blocking IO. That way
fgets should return even if there is not data. Then you can check if
that is that data you want and handle you error. this is the function
to set non blocking io on file pointers.
socket_set_blocking()
Check:
http://www.php.net/manual/function.set-socket-blocking.php
for more details.
:)
-jeremy brand
_______________________________________________________________________
GnuPG Fingerprint: 9F5E 95E0 1CC2 E054 84EA 6099 8ACD 9DBA D2C0 5EA9
_ http://www.jeremybrand.com/jeremy/brand/jeremy_brand.html
for more __