Sha256: 98dbb12f6c7653b7b6d3c6a74d8dc9117f30d76c553921c7670d91f9d56e6ed3

Contents?: true

Size: 567 Bytes

Versions: 17

Compression:

Stored size: 567 Bytes

Contents

# frozen_string_literal: true

require 'socket'

puts "Pid: #{Process.pid}"
server = TCPServer.open('127.0.0.1', 1234)
puts 'Echoing on port 1234...'
begin
  while (client = server.accept)
    Thread.new do
      while (data = client.gets)
        # client.send("you said: #{data.chomp}!\n", 0)
        client.write('you said: ', data.chomp, "!\n")
      end
    rescue Errno::ECONNRESET
      'Connection reset...'
    ensure
      puts "Closing client socket"
      client.shutdown
      client.close
    end
  end
ensure
  puts "Closing server"
  server.close
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
polyphony-1.6 examples/io/echo_server_plain_ruby.rb
polyphony-1.5 examples/io/echo_server_plain_ruby.rb
polyphony-1.4 examples/io/echo_server_plain_ruby.rb
polyphony-1.3 examples/io/echo_server_plain_ruby.rb
polyphony-1.2.1 examples/io/echo_server_plain_ruby.rb
polyphony-1.2 examples/io/echo_server_plain_ruby.rb
polyphony-1.1.1 examples/io/echo_server_plain_ruby.rb
polyphony-1.1 examples/io/echo_server_plain_ruby.rb
polyphony-1.0.2 examples/io/echo_server_plain_ruby.rb
polyphony-1.0.1 examples/io/echo_server_plain_ruby.rb
polyphony-1.0 examples/io/echo_server_plain_ruby.rb
polyphony-0.99.6 examples/io/echo_server_plain_ruby.rb
polyphony-0.99.5 examples/io/echo_server_plain_ruby.rb
polyphony-0.99.4 examples/io/echo_server_plain_ruby.rb
polyphony-0.99.3 examples/io/echo_server_plain_ruby.rb
polyphony-0.99.2 examples/io/echo_server_plain_ruby.rb
polyphony-0.99.1 examples/io/echo_server_plain_ruby.rb