java - Win8: DatagramSocket.send to multicast addr silently failes -
i trying write simple ssdp discovery routine upnp-enabled tv. here stripped-down version of code:
private void discover() { string header = "m-search * http/1.1"; string[][] fields = new string[][] { {"st", "ssdp:all"}, {"man", "\"ssdp:discover\""}, {"host", "239.255.255.250:1900"}, {"mx", "10"}}; string p=this.make_packet(header, fields); multicastsocket s = null; arraylist<string> devices=new arraylist<string>(); string[] ret; string[] loc; try { inetaddress addr=inetaddress.getbyname("239.255.255.250"); s = new multicastsocket(1900); s.setreuseaddress(true); s.setsotimeout(3000); s.joingroup(addr); datagrampacket pack=new datagrampacket(p.getbytes("utf-8"), p.length(), addr, 1900); s.send(pack); byte[] buffer=new byte[1024]; datagrampacket packrec=new datagrampacket(buffer, 1024); for(;;) { system.out.println("waiting response..."); s.receive(packrec); system.out.println(new string(buffer, 0, packrec.getlength())); } } catch (exception e) { system.out.println(e); } }
i compile , run code on win8 machine via console. socket received 1 response: 1:1 copy of message sent. correct, guess, since socket joins multicast group in beginning. however, no other upnp devices reply, although can see them in 3rd party upnp inspectors.
when watching network traffic wireshark, no package seems sent code @ all, although no exception thrown. when scanning network different upnp inspector same machine, outbound packages logged in wireshark (although oddly replies of devices not, though inspector finds them).
i messing around 4 days now, no avail. ideas?
thanks, eric
p.s.: jdk 1.8.0_45 (64bit)
Comments
Post a Comment