From: Eric Rubin Date: 2007-12-08T05:40:03+09:00 Subject: Re: winxp multicast socket reading problem I ran into this same problem and finally discovered that in Windows you have to call bind before setsockopt. This gets rid of the "setsockopt:Invalid argument(EINVAL)" message. Eric Rubin Akif Tokuz wrote: > > Hi > > I am trying to read some data from a multicast address. So I googled and > found this example. > > require 'socket' > require 'ipaddr' > > MULTICAST_ADDR = "225.4.5.6" > PORT = 5000 > > ip = IPAddr.new(MULTICAST_ADDR).hton + IPAddr.new("0.0.0.0").hton > > sock = UDPSocket.new > sock.setsockopt(Socket::IPPROTO_IP, Socket::IP_ADD_MEMBERSHIP, ip) > sock.bind(Socket::INADDR_ANY, PORT) > > loop do > msg, info = sock.recvfrom(1024) > puts "MSG: #{msg} from #{info[2]} (#{info[3]})/#{info[1]} len > #{msg.size}" > end > > But it didnt work again. Now it says > error on setsockopt:Invalid argument(EINVAL) > > What could be the problem? > > Thanks in advance. > > Akif, -- Posted via http://www.ruby-forum.com/.