Skip to content

Instantly share code, notes, and snippets.

@octosteve
Last active June 25, 2021 07:40
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save octosteve/17487d85c5493fb4404e to your computer and use it in GitHub Desktop.
Save octosteve/17487d85c5493fb4404e to your computer and use it in GitHub Desktop.
require 'socket' # Get sockets from stdlib
require 'pry'
server = TCPServer.open(9292) # Socket to listen on port 9292
puts "Server is running on port 9292"
loop { # Servers run forever
client = server.accept # Wait for a client to connect
puts client.recv(1000000)
client.puts "Go check the console!"
client.close # Disconnect from the client
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment