Luis G. wrote in post #969537:
> In the documentation says:
> - Check whether the transaction ID is equal to the one you choose - I
> got the same value '16', so I think is ok;
> - Check whether the action is connect - I got a '0'... Shouldn't I get a
> '1'?

Not from my reading of the description at
http://xbtt.sourceforge.net/udp_tracker_protocol.html

It says the 'connect input' packet is

Offset  Size  Name  Value
0  64-bit integer  connection_id  0x41727101980
8  32-bit integer  action  0
12  32-bit integer  transaction_id
16

and the 'connect output' packet is
Offset  Size  Name  Value
0  32-bit integer  action  0
4  32-bit integer  transaction_id
8  64-bit integer  connection_id
16

This is admittedly a pretty rubbish protocol document, but if you 
understand the semantics of each of these messages from some other 
reference, it might make sense to you.

> The next step is to fill the announce input and send it, so I can get
> the seeds and peers (my goal :)).
> I have one question here: All the fields are required, right? Because I
> don't really know some fields, like: peer_id, downloaded, left,
> uploaded, event, key. the field key, for example don't even appear in
> BitTorrent Tracker Protocol
> (http://wiki.theory.org/BitTorrent_Tracker_Protocol)

I'd say this is no longer anything to do with Ruby, but all about how to 
write a BitTorrent protocol implementation, and so this would be best 
answered on a BitTorrent mailing list. Sorry.

> Just one more question... The info_hash is a 20-byte string. To pack
> this variable, I can use the 'm' flag, right?

I doubt it, that would MIME-encode it. You probably want 'a20'

>> [-1,"foo",-1].pack("Na20N")
=> 
"\377\377\377\377foo\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\377\377\377\377"
>> [-1,"foobarfoobarfoobarfoobar",-1].pack("Na20N")
=> "\377\377\377\377foobarfoobarfoobarfo\377\377\377\377"

-- 
Posted via http://www.ruby-forum.com/.