[PHP] UDP problem
#1

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.

Код:
$fp = fsockopen('udp://' . $ip, $port, $errno, $errstr,0.0);
if (!$fp)
{
     echo 'Server is offline.';
}
else
{
...
}
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.
Reply


Messages In This Thread
[PHP] UDP problem - by scottyishere - 03.04.2011, 20:22
Re: [PHP] UDP problem - by Isset - 04.04.2011, 06:34
Re: [PHP] UDP problem - by Calgon - 04.04.2011, 06:43
Re: [PHP] UDP problem - by scottyishere - 04.04.2011, 06:56

Forum Jump:


Users browsing this thread: 1 Guest(s)