tehcrasx Posted October 30, 2008 Share Posted October 30, 2008 Hey all, I have a php application that connects to a server to get information but the server changes ports sometimes over a range. I need to be able to scan that range and find the port fairly quick. However after 100 checks php stops executing. Why is that? code: error_reporting(1); $port=0; $ip="192.168.1.66"; for($i=11100;$i<11999;$i++){ try{ $handle = socket_create(AF_INET,SOCK_DGRAM, SOL_UDP); if (!@socket_connect($handle,$ip,$i)) { throw new Exception( "$errno : $errstr <br/>"); }else{ socket_write($handle, "\\status\\"); if(!socket_read($handle, "2048")){ socket_close($handle); socket_clear_error($handle); throw new Exception("");} $port=$i; break; } }catch(Exception $e){ echo "not $i<br />"; echo $e->getMessage(); flush(); } } echo "<br />$port<br />"; Link to comment https://forums.phpfreaks.com/topic/130806-sockets-stop-connecting-after-100-attempts/ Share on other sites More sharing options...
bobbinsbro Posted October 31, 2008 Share Posted October 31, 2008 i may be wrong, but i think the script simply times out. port scanning is sloooow. Link to comment https://forums.phpfreaks.com/topic/130806-sockets-stop-connecting-after-100-attempts/#findComment-678927 Share on other sites More sharing options...
tehcrasx Posted October 31, 2008 Author Share Posted October 31, 2008 i may be wrong, but i think the script simply times out. port scanning is sloooow. it only takes <1 second to check 100 ports Link to comment https://forums.phpfreaks.com/topic/130806-sockets-stop-connecting-after-100-attempts/#findComment-678936 Share on other sites More sharing options...
bobbinsbro Posted October 31, 2008 Share Posted October 31, 2008 Link to comment https://forums.phpfreaks.com/topic/130806-sockets-stop-connecting-after-100-attempts/#findComment-678944 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.