Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 8fbab894d8
Fetching contributors…

Cannot retrieve contributors at this time

file 25 lines (19 sloc) 0.599 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
# Use in conjunction with ds_client.rb for testing puts/putc/gets/getc

require 'bundler/setup'
require 'socket'
require 'eventless'

server = TCPServer.new 2000

loop {
  while client = server.accept
      client.puts "One"
      client.puts "Hello!"
      client.puts "Nice to see you!\n"
      client.puts "Today would be improved by snails, don't you think?"
      client.putc "Two"

      tests = %w(three four five six seven eight nine ten).map do |word|
        Eventless.spawn { sleep Random.rand(6); client.puts word }
      end

      tests.each { |t| t.join }

      client.close
  end
}
Something went wrong with that request. Please try again.