source: de.wigbels.ruby/hothotread/archiv/sockconnect.rb@ 44fb3a7

Last change on this file since 44fb3a7 was c22952c, checked in by Norbert Wigbels <njw@…>, 9 years ago

Stromzaehler

  • Property mode set to 100644
File size: 325 bytes
Line 
1require 'socket'
2
3s = Socket.new(Socket::AF_INET, Socket::SOCK_STREAM, 0)
4sockaddr = Socket.sockaddr_in(2701, '192.168.14.42')
5begin
6s.connect(sockaddr)
7rescue
8 puts "error: #{$!}"
9else
10 s.print "version\r\n"
11 data = s.recvfrom(1024)
12 puts data
13 # and terminate the connection when we're done
14 s.close
15end
16
Note: See TracBrowser for help on using the repository browser.