require "socket" def handle_connection(socket) loop do payload_size = socket.read_bytes(Int32) raw_message = socket.read_string(payload_size) puts raw_message end rescue e puts "Disconnected from the Master Server" puts e end begin spawn do check = TCPSocket.new("0.0.0.0", 9300) check.tcp_nodelay = true puts "Successfully connected to the Master Server" handle_connection(check) end loop do sleep 1 end rescue e puts e end