Created
January 9, 2015 07:05
-
-
Save vigram/16660307a3ad01dbc9cc to your computer and use it in GitHub Desktop.
Simple TCP oriented messaging system
This file contains hidden or 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
client-side: | |
~~~~~~~~~~~ | |
require 'socket' | |
hostname = 'localhost' | |
port = 2000 | |
s = TCPSocket.open(hostname, port) | |
while line = s.gets | |
puts line.chop | |
end | |
server-side: | |
~~~~~~~~~~~ | |
require 'socket' | |
server = TCPServer.open(2000) | |
client = server.accept | |
client.puts "Hi I'm here !!!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment