regdude Posted May 3, 2009 Share Posted May 3, 2009 Hi! I made a simple query for a server, JK3 btw, because couldn't find any queries and LGSL always crashed my apache server. But there is a problem, I want to add the server monitor on a page, but the page wouldn't load if the server is down. This I have to connect to the server, but since UDP is connectionless then this can't be used if server is up. $fp = fsockopen("udp://ip", 29070, $errno, $errstr, 200); if (!$fp) { echo "ERROR: $errno - $errstr<br />\n"; } Also have this, but that doesn't seem to work. if(fwrite($fp, $packet)) { //... } How could I test if the server is up? Link to comment https://forums.phpfreaks.com/topic/156629-solved-server-query/ Share on other sites More sharing options...
Ken2k7 Posted May 3, 2009 Share Posted May 3, 2009 I'm not aware of what udp://ip is, but can't you check it against a page on your server? Say you have index.php on www.domain.com/index.php, then: $fp = @fsockopen('www.domain.com/index.php', 80, $errno, $errstr, 10); if (!$fp) echo 'Server is down'; Though, I like cURL more. Both should work though. Link to comment https://forums.phpfreaks.com/topic/156629-solved-server-query/#findComment-824744 Share on other sites More sharing options...
regdude Posted May 3, 2009 Author Share Posted May 3, 2009 Doesn't seem to work either. Link to comment https://forums.phpfreaks.com/topic/156629-solved-server-query/#findComment-824749 Share on other sites More sharing options...
Ken2k7 Posted May 3, 2009 Share Posted May 3, 2009 Actually, I think you should just test against the domain rather than the file. But I tested it myself and it works for me. Link to comment https://forums.phpfreaks.com/topic/156629-solved-server-query/#findComment-824757 Share on other sites More sharing options...
regdude Posted May 3, 2009 Author Share Posted May 3, 2009 I think you misunderstood what I'm making. The server I'm testing is not TCP (also not HTTP), but it is UDP. Link to comment https://forums.phpfreaks.com/topic/156629-solved-server-query/#findComment-824765 Share on other sites More sharing options...
regdude Posted May 3, 2009 Author Share Posted May 3, 2009 Where did the edit button go? Sorry about the double post then. I figured out that I could simply set a timer, but this isn't Assembler where 2 proccesses are ran in background. Luckily there is a function for a timer and already set for usage: socket_set_timeout($fp, 2); Link to comment https://forums.phpfreaks.com/topic/156629-solved-server-query/#findComment-824854 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.