Janka no Benzin Tanka Posted May 8, 2010 Report Share Posted May 8, 2010 (edited) Labdien! Man lūk ir šāds skripts: <?php $ip = "127.0.0.1"; $ports = "27051"; $socket = fsockopen("udp://".$ip, $ports); $cmd = "\xFF\xFF\xFF\xFF\x54Source Engine Query\x00"; $lenght = strlen($cmd); fwrite($socket, $cmd, $lenght); $response = fread($socket, 1); if (!empty($response)) { echo "<center><p style=\"font-size: 12px Tahoma; font-weight: bold; color: #00FF00;\">Online</p></center>"; } else { echo "<center><p style=\"font-size: 12px Tahoma; font-weight: bold; color: #ff4400;\">Offline</p></center>"; } ?> Viņš pārbauda, vai norādītais ports eksistē. Problēma tāda, ja ports neeksistē jeb process ir offline, tad viņš ļoti ilgi viņu lādē, apmēram minūti. Kad ports eksistē jeb process ir online, tad viņš monemtāli viņu pārbauda. Ko skriptam vajadzētu samainīt, lai viņš momentāli arī pārbaudītu, kad process ir offline? Edited May 8, 2010 by Janka no Benzin Tanka Quote Link to comment Share on other sites More sharing options...
Kavacky Posted May 8, 2010 Report Share Posted May 8, 2010 fsockopen ( string $hostname [, int $port [, int &$errno [, string &$errstr [, float $timeout]]]] ) Quote Link to comment Share on other sites More sharing options...
Janka no Benzin Tanka Posted May 8, 2010 Author Report Share Posted May 8, 2010 Nesanāk man k-kas, errorus met. Varbūt vari iekopēt visu skriptu pārtaisīto? Quote Link to comment Share on other sites More sharing options...
marrtins Posted May 8, 2010 Report Share Posted May 8, 2010 Varbūt iekopē errorus, a? Quote Link to comment Share on other sites More sharing options...
Janka no Benzin Tanka Posted May 8, 2010 Author Report Share Posted May 8, 2010 (edited) Skripts tagad izkatās šadi: <?php $ip = "127.0.0.1"; $ports = "27052"; $socket = fsockopen("udp://".$ip, $ports, $errno, $errstr, 1); $cmd = "\xFF\xFF\xFF\xFF\x54Source Engine Query\x00"; $lenght = strlen($cmd); fwrite($socket, $cmd, $lenght); $response = fread($socket, 1); if (!empty($response)) { echo "<center><p style=\"font-size: 12px Tahoma; font-weight: bold; color: #00FF00;\">Online</p></center>"; } else { echo "<center><p style=\"font-size: 12px Tahoma; font-weight: bold; color: #ff4400;\">Offline</p></center>"; } ?> Bet tāpat ilgi lādē. Varētu būt vaina FW? Jo k-kad sen, šis pirmais skripts strādāja perfekti. Tagad cits FW, un nestrādā tā kā vajag. Edited May 8, 2010 by Janka no Benzin Tanka Quote Link to comment Share on other sites More sharing options...
rATRIJS Posted May 8, 2010 Report Share Posted May 8, 2010 Labāk ej atpakaļ uz benzīntanku... http://uk.php.net/fsockopen Quote Link to comment Share on other sites More sharing options...
ezis Posted May 8, 2010 Report Share Posted May 8, 2010 (edited) monitorēt serveri taisies? ^^ stream_set_timeout($socket, 0, 800 * 1000); liec šo pēc fsockopen rindiņas ^^ tikai neuzliec par maz laiku.. kad tālāk liksi kvērijus, tad var arī attrūkties laika, lai iegūtu datus.. Edited May 8, 2010 by ezis Quote Link to comment Share on other sites More sharing options...
Janka no Benzin Tanka Posted May 9, 2010 Author Report Share Posted May 9, 2010 O, paldies! Tagad strādā gandrīz perfekti :) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.