我开发了多个 eventmachine 服务器,就像
require 'eventmachine'
module EchoServer
def post_init
puts "-- someone connected to the echo server!"
end
def receive_data data
send_data ">>>you sent: #{data}"
close_connection if data =~ /quit/i
end
def unbind
puts "-- someone disconnected from the echo server!"
end
end
EventMachine::run {
EventMachine::start_server "127.0.0.1", 8081, EchoServer
EventMachine::start_server "127.0.0.1", 8082, EchoServer
EventMachine::start_server "127.0.0.1", 8083, EchoServer
}
现在我只需要根据端口 8082 向客户端发送数据。如果我打开了所有连接。服务器需要将数据发送回特定的服务器。因此,如果从 8081 收到请求,我需要将其发送到 8082 客户端。我该如何发送?