question about UDP socket

Ned Konz ned at squeakland.org
Tue Oct 12 15:34:27 UTC 2004


On Tuesday 12 October 2004 5:35 am, danil a. osipchuk wrote:
> Hi, all
> Can somebody give me a hint why this doesn't work(unix vm 3.6-3, FreeBSD)?:
>
> dst _ Socket newUDP setPort: 55555.
> src _ Socket newUDP.
> src sendUDPData: 'a test' toHost:  (NetNameResolver localHostAddress)
> port:  dst port. " *primitive failed* here "
> src closeAndDestroy.
> buff _ Array new: 100.
> dst receiveUDPDataInto: buff.
> buff inspect.
> dst closeAndDestroy.


This works for me:

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 Konz
http://bike-nomad.com/squeak/



More information about the Squeak-dev mailing list