Advertisement
kiler129

Untitled

Mar 28th, 2016
227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.76 KB | None | 0 0
  1. <?php
  2. function _gs($s){echo "GOT SIG #$s\n";};
  3. pcntl_signal(SIGUSR1, '_gs');
  4.  
  5. var_dump(getmypid());
  6. $s = stream_socket_server('tcp://0.0.0.0:9999');
  7.  
  8. $rBase = [$s, fopen('php://stdin', 'r')];
  9. foreach($rBase as $set){
  10.  stream_set_blocking($set, 0);
  11. }
  12. while(true) {
  13.  $r = $rBase;
  14.  $w = [];
  15.  $e = $rBase;
  16.  
  17.  $ss = stream_select($r, $w, $e, null);
  18.  var_dump($ss, $r, $w, $e);
  19.  
  20.  foreach($r as $rt)
  21.  {
  22. //  var_dump(stream_set_blocking($rt, 0));
  23. echo "GET SNAME: ";
  24. var_dump(stream_socket_get_name($rt, false));
  25.  
  26.   if(stream_set_blocking($rt, 0) === false) {
  27.    echo "FOUND BROKEN STREAM!\n";
  28.    $index = array_search($rt, $rBase, true);
  29.    var_dump($index);
  30.    unset($rBase[$index]);
  31.   }
  32.  }
  33.  
  34.  echo "\n-------------------------------------\n";
  35.  sleep(1);
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement