-
-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cool.io::TCPServer continues to receive data even if its close method is called #61
Comments
You need to call |
I think this is expected behavior. So here is the correct code to shutdown coolio. require 'socket'
require 'cool.io'
HOST = '127.0.0.1'
PORT = 1234
class ServerConnection < Coolio::TCPSocket
def on_read(data)
puts "received: #{data}"
end
end
event_loop = Coolio::Loop.new
conns = []
server = Cool.io::TCPServer.new(HOST, PORT, ServerConnection) do |conn|
conns << conn
end
server.attach(event_loop)
server_thr = Thread.new { event_loop.run }
sock = TCPSocket.new(HOST, PORT)
puts "cool.io version: #{Coolio::VERSION}"
puts 'send a message'
sock.send "message", 0
sleep 1
server.close
conns.each do |c|
c.close
end
puts 'server stopped'
sleep 1
puts 'send a message'
sock.send "message", 0
sleep 1
puts 'done'
We can find another problem here. |
It sounds wrong to me, but please consider making a PR, as I don't think anyone is invested in maintaining this code base. |
I expect
Cool.io::TCPServer
to stop receiving data afterCool.io::TCPServer#close
is called, but it continues to receive data. Is this behavior expected?Here is a reproducible code:
Output
The text was updated successfully, but these errors were encountered: