From: "Luis G." Date: 2010-12-16T23:49:44+09:00 Subject: Re: How to do UDP calls Maybe I have not explained well... I'm basically sending requests to torrent trackers to get the number of seeds and peers of a torrent in a specific tracker. As you might know, you can have this: http://9.rarbg.com:2710/announce udp://tracker.openbittorrent.com:80/announce so, you can have http and udp trackers. For the first one (HTTP) I just use this: url = tracker_url + '?info_hash=%19%89B%0AL%87k%9A%2B%28%3A%B36%9D%93%9A%8D%FA%97I' agent = Mechanize.new do |a| a.history.max_size = 1 a.read_timeout = 60 end res = agent.get(url).save_as(path) with this I get a file with the number of seeds and peers on it. I just need to open the file in 'path' and extract the information. But for the second one (UDP) I can't use Mechanize, so I need to work with the standard library as you told before. I never used socket library before, so I'm kinda lost. I was trying something like: host = 'tracker.openbittorrent.com' port = 80 data = '%19%89B%0AL%87k%9A%2B%28%3A%B36%9D%93%9A%8D%FA%97I' sock = UDPSocket.open sock.connect(host, port) sock.send("?info_hash=" + data, 0) But there are some things here that I don't know: 1- The main idea is to create a socket, connect it to the remote host, send the request and get the response, right? 2- do I need to include the 'udp://' in the host? 3- is ok to include the name of the field I want to send (?info_hash=) in the data variable? I need to include that as you can see here: http://wiki.theory.org/BitTorrent_Tracker_Protocol 4- how can I get the response from the server? something like: sock.recvfrom(1024)? I tried several options and I had no success. Any clues? Thanks, Luis -- Posted via http://www.ruby-forum.com/.