PHP Socket timeout won't go below 0.5 seconds -


i'm trying scan ip range , info specific devices. problem is, although have so_rcvtimeo array('sec'=>0,'usec'=>1000) each request should timeout gets around 0.5 seconds. others on other hand take 0.005 seconds. can imagine if want scan big ip range i'm doomed.

what doing wrong or how can improve ?

below code

foreach($iparray $ip){     $result = array();     $buf = '';     $from = '';     $sock = socket_create(af_inet, sock_dgram, sol_udp);     socket_set_option($sock,sol_socket,so_rcvtimeo,$timeout);     socket_set_option($sock, sol_socket, so_broadcast, 1);     //socket_bind($sock, $from, 2048);     socket_set_option($sock, sol_socket, so_broadcast, 0);     socket_sendto($sock, $data1, strlen($data1), 0, $ip, 10001);     $time = microtime(true);     if(!socket_recvfrom($sock, $buf, 512000, 0, $from, $port)){         echo (microtime(true) - $time) . ' elapsed<br><br><br>';         continue;     }     echo (microtime(true) - $time) . ' elapsed<br><br><br>';     $result= parse_result(bin2hex($buf));     socket_close($sock); } 

note i'm creating separate socket each ip because reason otherwise results confused in between ips , same result twice.

running on windows bitnami machine.

thanks

turns out windows has minimum amount of timeout can set way higher on linux.

basically array('sec'=>0,'usec'=>1000) usec part of works in linux machines.


Comments

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

c# - Where does the .ToList() go in LINQ query result -

android - CollapsingToolbarLayout: position the ExpandedText programmatically -