Slide 92
Slide 92 text
require 'socket'
class Server
def start(bind: '0.0.0.0', port: nil)
sock = Socket.new(:INET, :STREAM)
sock.bind Addrinfo.tcp bind, port
sock.listen 0
client, client_addr = sock.accept
client.puts "Hello there! %s" % Time.now
client.close
sock.close
end
end
Server.new.start(port: 23333, bind: '127.0.0.1')