require 'socket' s = Socket.new(Socket::AF_INET, Socket::SOCK_STREAM, 0) sockaddr = Socket.sockaddr_in(2701, '192.168.14.42') begin s.connect(sockaddr) rescue puts "error: #{$!}" else s.print "version\r\n" data = s.recvfrom(1024) puts data # and terminate the connection when we're done s.close end