View Single Post
  #1  
Old October 8th, 2008
Atomical Atomical is offline
Novicius
 
Join Date: October 8th, 2008
Posts: 3
Atomical is flying high
Default Gnutella PHP,QRT example

I'm testing a PHP Gnutella client and I need to generate a QRT table so I can receive data and test the functionality. I read over the spec and I still can't figure this out or get it right. If anyone could shed some light on what I'm doing wrong that would be amazing! I suspect I'm not packing/formatting the binary data right. Here's my code:

PHP Code:
        //write QRP reset message
        
$variant = "\0x0";
        
$table_length = pack('V',65536);
        
$infinity = pack('C',1);
        
$packet = $variant . $table_length . $infinity;
        
$reset = create_header( "\30x0", 1,0, $packet );
        
        
fwrite($fp, $reset,strlen($reset));
        
        
        
//4 kilobyte
        
$byte = '';
        for ( 
$o = 0; $o < 8/*(1024*4)*/; $o++){
            
$byte .= 1;
            
//$byte .= bindec(1111);
            //$byte .= pack('C',1); 
        
        
}
        
        
        
//write qrp table
        
$packet = '';
        for ( 
$t =0; $t < 16; $t++ ){
    
            
$variant = "\0x1";
            
$seq_no = pack('C',$ttt = $t+1);
            echo 
"Patch $ttt of 16\n";
            
$seq_size = pack('C',16); //bits
            
$compressor = "\0x0";
            
$entry_bits = pack('C',8);
            
$packet = $variant . $seq_no . $seq_size . $compressor . $entry_bits . $byte;
            
            
$packet = create_header("\30x0",1,0,$packet);
            
            

            
fwrite($fp,$packet, strlen($packet));
            
        
        } 
Reply With Quote