php - can't get stream_set_timeout to work in foreach array loop -
i'm not familiar php have been able script running check if port open number of local network computers. downside pc's offline , can't timeout of fsockopen function lower 1 second (0.001 second enough)
i've found *stream_set_timeout* function can't seem work. i'm pretty sure it's in wrong place, , hope can point out should go.
now error:
warning: stream_set_timeout() expects parameter 1 resource, boolean given
snippet:
$timeout = 1000; foreach ($farm $pc){ $check = @fsockopen($pc, $port); stream_set_timeout($check,0,$timeout);   if (is_resource($check))  {    echo $pc . " online";           fclose($check); } else {    echo $pc . " offline"; }  }   current solution:
foreach ($farm $pc){ $check = @fsockopen($pc,$port,$errcode,$errstr,0.001);    if (is_resource($check))  {    echo $pc . " online";           fclose($check); } else {    echo $pc . " offline"; }  }       
 
  
Comments
Post a Comment