Luis G. wrote in post #969040: > first question, shouldn't the array just contain 3 element? > 64-bit integer connection_id 0x41727101980 > 32-bit integer action 0 > 32-bit integer transaction_id 16 A 64-bit integer is 8 bytes, and two 32-bit integers are 8 bytes. The problem is you want to pack 0x123456789abcdef as 0123456789abcdef, ut the 'q' option to pack gives something else (on Intel-machines nyway): >> n = 0x123456789abcdef => 81985529216486895 >> [n].pack("q") => "\357\315\253\211gE#\001" >> [n].pack("q").unpack("H*").first => "efcdab8967452301" You want to send it in network-byte order, MSB first. There's no unction in pack to do this, but "N" packs 32-bits in network-order. So: >> [n>>32,n&((1<<32)-1)].pack("NN") => "\001#Eg\211\253\315\357" >> [n>>32,n&((1<<32)-1)].pack("NN").unpack("H*").first => "0123456789abcdef" Mind you, if the only thing to need to do is check the conn_id is the ame, maybe you will get away with "q" if you use it the same for acking and unpacking. > I tried to run the script with the information you gave me. ... > And actually now I have something in the 'response' variable. If I print > the content I got something like > > ["\000\000\000\000\000\000\000\020#B\005\027�ÁP\377", > ["AF_INET", 80, "tracker.openbittorrent.com", "95.215.62.5"]] > > And STDERR.puts response.unpack("H*").first will return >>> 000000000000001023420517de4150ff > > In the documentation says that 'Check whether the transaction ID is > equal to the one you chose.'. So basically I should get the same value I > sent, right? The result is an array of two elements, the data and the address info. Take the first element, then look at data.unpack("NNq") or ata.unpack("NNNN"). To handle the byte-ordering problem again: action, trans_id, c0, c1 = data.unpack("NNNN") conn_id = (c0 << 32) | c1 (note that they come in a different order in the response than in the equest)