Jump to content

fsockopen timeout


ttocskcaj

Recommended Posts

I am using this code to check if a server is running. Everything is fine when it is running, but when it's not, it takes ages for the fsockopen to fail. Is there a way to make it timeout faster?

    
if (fsockopen($settings->survival_server, $settings->survival_port, $timeout = 0.1)){
        $survival['status'] = "Up";
    }else {
        $survival['status'] = "Down"
}

Link to comment
https://forums.phpfreaks.com/topic/232153-fsockopen-timeout/
Share on other sites

Cool thanks. That works. What was wrong with the way I was doing it?

 

PHP doesn't support named parameters unfortunately.  If you have a list of optional params you have to specify all the ones you need up to the option you require.  There's no way to cherry pick one option in the way you were attempting to.

Link to comment
https://forums.phpfreaks.com/topic/232153-fsockopen-timeout/#findComment-1195757
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.