Last active
June 25, 2021 07:40
-
-
Save octosteve/17487d85c5493fb4404e to your computer and use it in GitHub Desktop.
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' # 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