HilaireFernandes wrote > Thanks Sven for the indications. > > Of course I already looked at this Test, but I got lost. I looked at it > again, and wrote something like: > > | socket data | socket := Socket newUDP. socket setPort: 9999. > socket waitForConnectionFor: 2; waitForDataFor: 5 . data := Array > new: 100. [socket receiveUDPDataInto: data. data crLog] > ensure: [ 'Closing socket' crLog. socket closeAndDestroy] > > I do not have error, but a time out. > > Dr. Geo > http://drgeo.eu
With UDP, there is no connection concept, so I'd reckon waitForConnectionFor: is what gives you a TimeOut error... Delete that, only use waitForDataFor: n , put it in a loop (so it won't stop listening until it receives a request), and you should be fine. Doesn't quite look like neither server nor client yet, the workflow should be something like: 1) server (you) starts, listening to port you're using and waitsForData: in an infinite loop. 2) client (student) starts, sends request to broadcast address/port, then waitsForData: on the socket it created. 3) broadcast server reads request, generates reply, and sends it to the originIP/port of the request 4) client receives reply, handles it, and closes socket. Cheers, Henry PS. Why use nc when you already have a working broadcast client in pharo? ;) -- Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html