Next | 5.2 Networking | Prev |
require 'socket' client = TCPSocket.open('localhost', 'finger') client.send("migo\n", 0) # 0 means standard packet puts client.readlines client.close
Login: migo Name: Mikhael Goikhman Directory: /home/migo Shell: /bin/tcsh On since Tue Sep 23 21:24 (IDT) on tty6 4 days 3 hours idle No mail.
Simple HTTP request example:
require 'net/http' conn = Net::HTTP.new('demo.cortext.co.il', 80) resp, data = conn.get('/images/', nil) if resp.message == "OK" data.scan(/<a [^>]+>(r.*?\.png)</) { |x| puts x } end
rui_logo_large.png rui_logo_small.png rye1.png rye2.png
Next | Ruby for Perl programmers | Prev |