From: "Luis G." Date: 2010-12-17T02:15:19+09:00 Subject: Re: How to do UDP calls Hey man, thanks for your reply. I read the documentation but this is hard for me... But actually I don't have enough skills to do this without help... So, as far as I understood in the structures section of the UDP tracker protocol documentation, the first thing I need to do is: 1. Choose a (random) transaction ID. 2. Fill the connect input structure. 3. Send the packet. connect input 64-bit integer connection_id 0x41727101980 32-bit integer action 0 32-bit integer transaction_id 16 You told me that Array#pack will help me. This means that I need to put the the content of the connect input in an array and pack it so I can send it, right? Actually I thought we need to have something like: connection_id =>0x41727101980 action => 0 ... Anyway, see this example: data = Array.new data << 0x41727101980 #connection_id data << 0 #action data << 16 #transaction_id host = 'tracker.openbittorrent.com' port = 80 s = data.pack('q') #q?! sock = UDPSocket.open sock.connect(host, port) sock.send(s, 0) response = sock.recvfrom(1024) After this I should: 1. Receive the packet (response). 2. Check whether the packet is at least 16 bytes. 3. Check whether the transaction ID is equal to the one you chose. 4. Check whether the action is connect. 5. Store the connection ID for future use. You can see something wrong with this code? BTW, I tried echo "GET /announce" | nc -u tracker.openbittorrent.com 80 sudo tcpdump -i eth0 -nn -s0 udp port 80 and I got results: 18:09:14.719638 IP 192.168.182.123.57232 > 95.215.62.26.80: UDP, length 14 Thanks a lot, Luis -- Posted via http://www.ruby-forum.com/.