How to Build a Web App with and without Rails Libraries
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'socket' | |
server = TCPServer.new(1337) | |
loop do | |
client = server.accept | |
client.puts "What's your name?" | |
input = client.gets | |
puts "Received #{input.chomp} from a client socket on 1337" | |
client.puts "Hi, #{input.chomp}! You've successfully connected to the server socket." | |
puts "Closing client socket" | |
client.puts "Goodbye #{input}" | |
client.close | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment