Squeak SmalltalkJoker Squeak Smalltalk : Network : prevnext UDP Socket

dst _ Socket newUDP setPort: 55555.
src _ Socket newUDP.
buff _ ByteArray new: 100.
delay _ Delay forMilliseconds: 100.
localhost _ ByteArray withAll: { 127. 0. 0. 1 }.
received := nil.

rp := [[ received := dst receiveUDPDataInto: buff.
 received first  isZero ] whileTrue: [ delay wait ].
 WorldState addDeferredUIMessage: [ { buff. received } inspect ]] fork.

src sendUDPData: 'a test' toHost: localhost port:  dst port.

src closeAndDestroy.
dst closeAndDestroy.

-- 
Ned

--
Thanks Ned & Jan, finally I've got it (really subtle matter). The 
simplest form working for me:

dst _ Socket newUDP setPort: 55555.
src _ Socket newUDP.
src sendUDPData: 'a test' toHost:  (ByteArray withAll: {127. 0. 0. 1.})  
port:  dst port.
buff _ ByteArray new: 100.
dst receiveUDPDataInto: buff.
buff inspect.
dst closeAndDestroy.
src closeAndDestroy.
src := dst := nil.

My mistakes: NetNameResolver localhost gave me 192.168.20.21 (thanks Ned 
) and wrong array type (thanks Jan). Latest Ned's example works also. I 
wonder a bit - why UDP send fails (it should not I think),  but anyway - 
it works in some way

--
Thanks Ned & Jan, finally I've got it (really subtle matter). The 
simplest form working for me:

dst _ Socket newUDP setPort: 55555.
src _ Socket newUDP.
src sendUDPData: 'a test' toHost:  (ByteArray withAll: {127. 0. 0. 1.})  
port:  dst port.
buff _ ByteArray new: 100.
dst receiveUDPDataInto: buff.
buff inspect.
dst closeAndDestroy.
src closeAndDestroy.
src := dst := nil.

My mistakes: NetNameResolver localhost gave me 192.168.20.21 (thanks Ned 
) and wrong array type (thanks Jan). Latest Ned's example works also. I 
wonder a bit - why UDP send fails (it should not I think),  but anyway - 
it works in some way