Created
November 23, 2016 22:42
-
-
Save anonymous/7da948629ea906d1f58c252bc95e06ff 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 "json" | |
server = TCPServer.open(2000) # Socket to listen on port 2000 | |
loop { # Servers run forever | |
client = server.accept # Wait for a client to connect | |
my_hash = { :numbers => [1, 3, 6], :text => "test"} | |
client.puts(JSON.generate my_hash) # Send the json text to the client | |
client.close # Disconnect from the client | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment