Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env ruby
- # Program: Hello_World_clt.rb
- # Sample code adapted from TutorialsPoint. (2014). Ruby socket programming.
- # Retrieved from http://www.tutorialspoint.com/ruby/ruby_socket_programming.htm
- require 'socket' # Sockets are in standard library
- hostname = 'localhost'
- port = 10080
- s = TCPSocket.open(hostname, port)
- while line = s.gets # Read lines from the socket
- puts line.chop # And print with platform line terminator
- end
- s.close # Close the socket when done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement