Sha256: ad099562c29403deafb5193b2617b65cc1a4dc26cc20801e4030e674202455ec

Contents?: true

Size: 728 Bytes

Versions: 10

Compression:

Stored size: 728 Bytes

Contents

#!/usr/bin/env ruby

$LOAD_PATH << File.expand_path("../../lib", __dir__)

require 'set'

require 'async/reactor'
require 'async/io/host_endpoint'
require 'async/io/protocol/line'

class Server
	def initialize
		@connections = []
	end
	
	def run(endpoint)
		Async do |task|
			task.async do |subtask|
				while true
					subtask.sleep 10
					puts "Connection count: #{@connections.count}"
				end
			end
				
			
			endpoint.accept do |peer|
				stream = Async::IO::Stream.new(peer)
				
				@connections << stream
			end
		end
	end
end

Async.logger.level = Logger::INFO
Async.logger.info("Starting server...")
server = Server.new

endpoint = Async::IO::Endpoint.parse(ARGV.pop || "tcp://localhost:7234")
server.run(endpoint)

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
async-io-1.24.0 examples/millions/server.rb
async-io-1.23.3 examples/millions/server.rb
async-io-1.23.1 examples/millions/server.rb
async-io-1.23.0 examples/millions/server.rb
async-io-1.22.0 examples/millions/server.rb
async-io-1.21.0 examples/millions/server.rb
async-io-1.20.0 examples/millions/server.rb
async-io-1.18.5 examples/millions/server.rb
async-io-1.18.4 examples/millions/server.rb
async-io-1.18.3 examples/millions/server.rb