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
と動作します..
ありがとう