$MYUID, 'to_uid'=>$uid, 'message'=>$words))); continue; } // 向所有用户发消息 fwrite($sock, JsonProtocol::encode(array('from_uid'=>$MYUID, 'to_uid'=>'all', 'message'=>$ret))); continue; } } } function read_data($socket) { $buf = stream_socket_recvfrom($socket, 4); if($buf == '') { return; } $remain_len = JsonProtoCol::check($buf); //echo '$remain_len:'.$buf.':'.bin2hex($buf).":".$remain_len."\n"; $buf .= stream_socket_recvfrom($socket, $remain_len); stream_set_blocking($socket, 0); //echo '$buf:'.$buf."\n"; return JsonProtocol::decode($buf); }