From: "Luis G." Date: 2010-12-20T19:40:31+09:00 Subject: Re: How to do UDP calls Hello again. Thanks for your explanation. I understood that we need to split a 64bit integer in two 32 bit integer and pack them in network-byte order. So, as you said: connection_id = 0x41727101980 pp connection_id >> 4497486125440 s = [connection_id >> 32, connection_id & 0xffffffff, 0, 16].pack('NNNN') c0, c1, action, trans_id = s.unpack("NNNN") conn = (c0 << 32) | c1 pp conn >> 4497486125440 pp action >> 0 pp trans_id >> 16 I did this small test like you explained and I get the same values after pack and unpack the information(connection_id = conn). So, after I pack the data, I send it and I get a response: sock = UDPSocket.open sock.connect(host, port) sock.send(s, 0) response = sock.recvfrom(1024) so, I extract the content of the response like this (using a different order of the request): action, trans_id, c0, c1 = response[0].unpack("NNNN") conn_id = (c0 << 32) | c1 pp action >> 0 pp trans_id >> 16 pp conn_id >> 2540598739861590271 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'? 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) Just one more question... The info_hash is a 20-byte string. To pack this variable, I can use the 'm' flag, right? Thanks, Luis Goncalves -- Posted via http://www.ruby-forum.com/.