Hi Manfred, Did you see/study the example/test UDPSocketEchoTest ?
Also, UDP is very primitive: it is send and forget, returns no errors, and is totally asynchronous. Listening should best be done in a separate process. Here is how I would write your send part: | message udpSocket | message := String crlf join: #( 'M-SEARCH * HTTP/1.1' 'HOST:239.255.255.250:1900' 'MAN:"ssdp:discover' 'ST:ssdp:all' 'MX:1' ''). udpSocket := Socket newUDP. udpSocket sendData: message toHost: #[239 255 255 250] port: 1900. udpSocket waitForSendDoneFor: 5. udpSocket closeAndDestroy. Maybe nothing came back because the line ends where wrong ? HTH, Sven > On 18 May 2015, at 11:29, Manfred Kröhnert <mkroehner...@googlemail.com> > wrote: > > Hello everyone, > > I am currently trying to get a list of UPnP device via SSDP (Simple Service > Discovery Protocol). > > A minimalistic working NodeJS example looks like this: > > var dgram = require('dgram'); > var message = new Buffer( > "M-SEARCH * HTTP/1.1\r\n" + > "HOST:239.255.255.250:1900\r\n" + > "MAN:\"ssdp:discover\"\r\n" + > "ST:ssdp:all\r\n" + > "MX:1\r\n" + > "\r\n" > ); > > var client = dgram.createSocket("udp4"); > > client.on("message", function (msg, rinfo) { > console.log("server got: " + msg + " from " + rinfo.address + ":" + > rinfo.port); > }); > client.send(message, 0, message.length, 1900, "239.255.255.250"); > client.close(); > > I tried to recreate the same functionality in Pharo with the following piece > of code: > > | message udpSocket host | > message := 'M-SEARCH * HTTP/1.1\r\n' , > 'HOST:239.255.255.250:1900\r\n' , > 'MAN:"ssdp:discover"\r\n' , > 'ST:ssdp:all\r\n' , > 'MX:1\r\n' , '\r\n'. > > udpSocket := Socket newUDP. > host := (NetNameResolver addressFromString: '239.255.255.250'). > udpSocket sendData: message toHost: host port: 1900. > "udpSocket waitForData." > Transcript show: 'Received: ' , udpSocket receiveData. > udpSocket closeAndDestroy. > > Unfortunately, this script hangs both in Pharo3 and Pharo4 (OS X 10.10, Pharo > 30856 and 40611). > When I interrupt with Cmd+. the debugger shows the method > Socket>>waitForDataIfClosed: > and the hang is apparently in the line > self readSemaphore wait > > Could anyone give me some advice if I should to do this differently or what > the issue with the Pharo script is? > > Thanks in advance, > Manfred