Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function _gs($s){echo "GOT SIG #$s\n";};
- pcntl_signal(SIGUSR1, '_gs');
- var_dump(getmypid());
- $s = stream_socket_server('tcp://0.0.0.0:9999');
- $rBase = [$s, fopen('php://stdin', 'r')];
- foreach($rBase as $set){
- stream_set_blocking($set, 0);
- }
- while(true) {
- $r = $rBase;
- $w = [];
- $e = $rBase;
- $ss = stream_select($r, $w, $e, null);
- var_dump($ss, $r, $w, $e);
- foreach($r as $rt)
- {
- // var_dump(stream_set_blocking($rt, 0));
- echo "GET SNAME: ";
- var_dump(stream_socket_get_name($rt, false));
- if(stream_set_blocking($rt, 0) === false) {
- echo "FOUND BROKEN STREAM!\n";
- $index = array_search($rt, $rBase, true);
- var_dump($index);
- unset($rBase[$index]);
- }
- }
- echo "\n-------------------------------------\n";
- sleep(1);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement