Advertisement
tsinclai2002

#52Weeks of Code Week 5 - Ruby - Client

Feb 6th, 2014
259
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.51 KB | None | 0 0
  1. #!/usr/bin/env ruby
  2. # Program: Hello_World_clt.rb
  3. # Sample code adapted from TutorialsPoint. (2014). Ruby socket programming.
  4. # Retrieved from http://www.tutorialspoint.com/ruby/ruby_socket_programming.htm
  5.  
  6. require 'socket'      # Sockets are in standard library
  7.  
  8. hostname = 'localhost'
  9. port = 10080
  10.  
  11. s = TCPSocket.open(hostname, port)
  12.  
  13. while line = s.gets   # Read lines from the socket
  14.   puts line.chop      # And print with platform line terminator
  15. end
  16. s.close               # Close the socket when done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement