当我在端口open_datagram_socket
上尝试1900
时出现以下错误:
/Users/timbaas/.rvm/gems/ruby-1.9.3-p194/gems/eventmachine-1.0.0/lib/eventmachine.rb:859:in `open_udp_socket': no datagram socket (RuntimeError)
from /Users/timbaas/.rvm/gems/ruby-1.9.3-p194/gems/eventmachine-1.0.0/lib/eventmachine.rb:859:in `open_datagram_socket'
from /Users/timbaas/Applications/ruby/upnp/ssdp.rb:36:in `block in initialize'
from /Users/timbaas/.rvm/gems/ruby-1.9.3-p194/gems/eventmachine-1.0.0/lib/eventmachine.rb:187:in `call'
from /Users/timbaas/.rvm/gems/ruby-1.9.3-p194/gems/eventmachine-1.0.0/lib/eventmachine.rb:187:in `run_machine'
from /Users/timbaas/.rvm/gems/ruby-1.9.3-p194/gems/eventmachine-1.0.0/lib/eventmachine.rb:187:in `run'
from /Users/timbaas/Applications/ruby/upnp/ssdp.rb:35:in `initialize'
from upnp.rb:4:in `new'
from upnp.rb:4:in `<main>'
我在Ruby 1.9.3上使用以下代码:
module SSDP
IP = "239.255.255.250"
PORT = 1900
class Server < EM::Connection
def receive_data(data)
p "d" + data
end
end
class Socket
attr_accessor :socket
def initialize
EventMachine::run do
@socket = EM::open_datagram_socket SSDP::IP, SSDP::PORT, SSDP::Server
p "Started EchoServer on #{SSDP::IP}:#{SSDP::PORT}..."
end
end
end
end
Socket.new
当我使用端口1901
时,它可以工作..
由于