ttocskcaj Posted March 30, 2011 Share Posted March 30, 2011 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 More sharing options...
gizmola Posted March 30, 2011 Share Posted March 30, 2011 Try this instead: if (fsockopen($settings->survival_server, $settings->survival_port, $errno, $errstr, 0.1)) { Link to comment https://forums.phpfreaks.com/topic/232153-fsockopen-timeout/#findComment-1194235 Share on other sites More sharing options...
ttocskcaj Posted March 31, 2011 Author Share Posted March 31, 2011 Cool thanks. That works. What was wrong with the way I was doing it? Link to comment https://forums.phpfreaks.com/topic/232153-fsockopen-timeout/#findComment-1194904 Share on other sites More sharing options...
gizmola Posted April 2, 2011 Share Posted April 2, 2011 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 More sharing options...
ttocskcaj Posted April 3, 2011 Author Share Posted April 3, 2011 Ah ok. They should really change that lol Link to comment https://forums.phpfreaks.com/topic/232153-fsockopen-timeout/#findComment-1196148 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.