|  PHP interesse |  | Goede nacht  
 Ik ben bezig met een IRC bot voor php, alleen deze gebruikt 100% cpu usage door de infinite while loop
 
 
 
    
    
        
            
                
  // Starts the bot, connects to the network and gets incomming lines
  public function run() {
    
    // Open connection
    $this -> class_connection -> connect();
    
    // Monitors the IRC connections and handles incomming lines
    while ( count( $arr_sockets = $this -> class_settings -> get( 'sockets' ) ) > 0 ) {
      
      // Split socket array
      $arr_read = $arr_write = $arr_sockets;
      
      // Select a stream
      $stream = stream_select( $arr_read , $arr_write , $except = NULL , $this -> class_settings -> get( 'settings' , 'timeout' , 'connection' ) );
      if ( $stream > 0 ) {
        
        // Check readable sockets
        foreach ( $arr_read AS $read ) {
          
          // Get socket id
          $socket_id = array_search( $read , $arr_sockets );
          
          // Get Line and handle it
          if ( $line = fgets( $read , 4096 ) ) {
            $this -> handle_line( $socket_id , $line );
          }
        }
      }
    }
  }
 // Starts the bot, connects to the network and gets incomming lines  public function run() {     // Open connection    $this -> class_connection -> connect();     // Monitors the IRC connections and handles incomming lines    while ( count( $arr_sockets = $this -> class_settings -> get( 'sockets' ) ) > 0 ) {       // Split socket array      $arr_read = $arr_write = $arr_sockets;       // Select a stream      $stream = stream_select( $arr_read , $arr_write , $except = NULL , $this -> class_settings -> get( 'settings' , 'timeout' , 'connection' ) );      if ( $stream > 0 ) {         // Check readable sockets        foreach ( $arr_read AS $read ) {           // Get socket id           // Get Line and handle it          if ( $line = fgets( $read , 4096 ) ) {            $this -> handle_line( $socket_id , $line );          }        }      }    }  }
   
 Weet iemand hoe ik kan zorge dat hij sockets blijft lezen maar niet zoveel CPU gebruikt. ?
 |