#!/usr/bin/env ruby require 'socket' port = (ARGV[0] || 7777).to_i TCPServer.open('localhost', port) do |svr| loop do #do-while loop sk = svr.accept input = sk.gets puts "RECV >>>#{input.chomp}<<<" sk.puts input puts "SENT >>>#{input.chomp}<<<" sk.close break if input.downcase.chomp == 'quit' end #end do-while loop end
I am exploring two new languages and a Distributed VCS. Go and Node.js. Go has Goroutines (sorta evented, sorta threaded) and Node.js is intrinsically event driven. Git is a VCS born of Linus Torvalds mind (tried Mercuria[hg] but git has won me and the majority over).
Friday, January 28, 2011
Echo Socket (single thread, single connection)
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment