Thanks for the tips, but like I said I think it's a php problem they've yet to address.
In your link example (yes I looked at all that stuff on php.net btw) lets look at the problem again:
PHP Code:
$fp = fsockopen("www.example.com", 80);
if(!$fp) {
echo "Unable to open\n";
} else {
fputs($fp, "GET / HTTP/1.0\n\n" );
$start = time();
stream_set_timeout($fp, 2);
$res = fread($fp, 2000);
var_dump(stream_get_meta_data($fp));
fclose($fp);
print $res;
}
creates the same problem because the code never gets past this:
PHP Code:
$fp = fsockopen("www.example.com", 80);
or @ least never gets past thisit just hangs there if it doesn't get anything.
Here's an example of my code
PHP Code:
$fp = fsockopen("udp://" . $address, $port, $errno, $errstr, 2);
if (!$fp)
{
$error = "ERROR: Unable to connect <br />\n";
}
else
{
//do this
}
the code will NEVER Set the error message because if it's not getting anything back it will just timeout. Note the 2. It's suppose to timeout after 2 seconds if it doesn't connect but it's not working.
OMG!
Just typing this I think I found my answer. udp is a connectionless protocal.
You never make a connection. duh! [img]images/smilies/tongue.gif[/img]
hmmm, so i wonder what to do if the server isn't up? [img]images/smilies/confused.gif[/img]
Is there a way to "listen" to a udp broadcast for a specific amount of time then close socket reguardless? Then I could put "any" info gathered into a variable & check to see if it's empty or not.
Bookmarks