Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.39 KB | None | 0 0
  1. require 'socket'
  2.  
  3. class Server
  4. def initialize()
  5. @server_socket = TCPServer.new("127.0.0.1", 3000)
  6. run
  7. end
  8.  
  9. def run
  10. loop do
  11. connection = @server_socket.accept
  12.  
  13. puts connection.read
  14.  
  15. connection.puts 'hey im putting things'
  16. connection.send 'hey', 0
  17. connection.print 'Hey from ruby\r\n'
  18. connection.close_write
  19.  
  20. connection.close
  21. end
  22. end
  23. end
  24.  
  25.  
  26. Server.new()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement