03.04.2011, 20:22
Hello!
I have a little PHP question.
I am trying to retrieve data from my server. Everything is working fine when server is online, but when the server is offline, the page continues to load 60 seconds longer and doesn't even display the "OFFLINE" message.
I've read on the PHP website that udp don't have a real 'connection' and if the host is unreachable it won't return a error (FALSE @ $fp). Though it said it will return at fwrite or fread. But the problem is that it never leaves fsockopen function.
Do you have any ideas how to fix this? Maybe a connection checker before opening a socket.
I'm very curious how this (http://typefish.co.uk/samp-conn/) is working, it's fast and doesn't hang if host is unreachable.
Thanks.
I have a little PHP question.
I am trying to retrieve data from my server. Everything is working fine when server is online, but when the server is offline, the page continues to load 60 seconds longer and doesn't even display the "OFFLINE" message.
Код:
$fp = fsockopen('udp://' . $ip, $port, $errno, $errstr,0.0); if (!$fp) { echo 'Server is offline.'; } else { ... }
Do you have any ideas how to fix this? Maybe a connection checker before opening a socket.
I'm very curious how this (http://typefish.co.uk/samp-conn/) is working, it's fast and doesn't hang if host is unreachable.
Thanks.