You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Dec 7, 2018. It is now read-only.
The following example fails unless line 8 is commented out:
#!/usr/bin/env ruby
#
# Run this as: bundle exec examples/echo_server.rb
require 'bundler/setup'
require 'celluloid/io'
Celluloid.task_class = Celluloid::TaskThread
class Server
include Celluloid::IO
finalizer :finalize
def initialize
async.run
end
def run
@handler = UDPHandler.new("0.0.0.0", 8000)
loop do
puts @handler.inspect
sleep 10
end
end
end
class UDPHandler
include Celluloid::IO
finalizer :finalize
def initialize(host, port)
puts "*** Starting echo server on #{host}:#{port}"
# Since we included Celluloid::IO, we're actually making a
# Celluloid::IO::TCPServer here
@server = UDPSocket.new
@server.bind(host, port)
async.run
end
def finalize
@server.close if @server
end
def run
loop { handle_connection }
end
def handle_connection
data, (_, port, host) = @server.recvfrom(1024)
puts "*** Received connection from #{host}:#{port}"
@server.send(data, 0, host, port)
rescue => error
puts "*** #{error.inspect}"
end
end
supervisor = Server.supervise
trap("INT") { supervisor.terminate; exit }
sleep
You can test the server by running:
dig @localhost -p 8000 dev.mydomain.org A
It works fine once, then the 2nd time, it gets stuck inside recvfrom. Is this correct behaviour?
The text was updated successfully, but these errors were encountered:
I believe this issue is related to celluloid/celluloid#432 as this has been merged this should now be working - could form the basis of a spec for that bug/issue.
The following example fails unless line 8 is commented out:
You can test the server by running:
It works fine once, then the 2nd time, it gets stuck inside
recvfrom
. Is this correct behaviour?The text was updated successfully, but these errors were encountered: