UDP dataAvailable twice, why?

Ragnar Hojland Espinosa ragnar at linalco.com
Wed Feb 19 22:33:49 UTC 2003

TCP was easy.. UDP is intriguing me a bit :)  I have the following code,
which should block until there's a datagram available and read it.  And so
it does, but after a complete read of a datagram (36 bytes) and on the next
while loop, both waitForData and dataAvailable return true immediately.. but
count is 0.

Why is this so?

	    udp _ Socket newUDP.
	    udp setPort: 6666.
	    [self isRunning] whileTrue: [
	    	  (udp waitForDataUntil: Socket standardDeadline)
		  ifTrue: [
		  	  udp dataAvailable ifTrue: [
			      | ip count buffer |
			      buffer _ ByteArray new: 8192.
			      ip _ udp remoteAddress.
			      count _ udp receiveDataInto: buffer.
			      udpQueue nextPut: buffer.			      
Ragnar Hojland - Project Manager
Linalco "Especialistas Linux y en Software Libre"
http://www.linalco.com Tel: +34-91-5970074 Fax: +34-91-5970083

More information about the Squeak-dev mailing list