You are on page 1of 1

class Client def start() require 'socket' begin s = TCPSocket.new 'localhost',2000 while line = s.

gets puts line end s.close rescue puts "Error with connection\n" end end end class Server def start() require 'socket' server = TCPServer.new 2000 loop do client = server.accept client.puts "Hello " client.puts "The time is #{Time.now}\n" client.close end end end

You might also like