question about UDP socket

Ned Konz ned at squeakland.org
Wed Oct 13 15:01:08 UTC 2004


On Wednesday 13 October 2004 1:55 am, danil a. osipchuk wrote:
> To be honest - not :) It seems this is  almost impassable terrain. I've
> built  3.7b-5 vm and still I can't run Ned's example.
> Maybe someone else try it in unix vm?

Try this. I was selecting chunks by hand in the Workspace, and the delay 
between the sendUDPData and the socket close was helping.


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.

(Delay forSeconds: 1) wait.

src closeAndDestroy.
dst closeAndDestroy.
src := nil.
dst := nil.

-- 
Ned Konz
http://bike-nomad.com/squeak/



More information about the Squeak-dev mailing list