[Cuis-dev] [QUESTION] Get all receivable data from a socket strem

Gerald Klix cuis.01 at klix.ch
Mon Dec 6 10:29:09 PST 2021


Hi all,

How can I get all receivable data from an instance
of SocketStream and block if there is no data to be received?
I did not find any method with that semantics
and came up with the attached #nextReceivable-method,
but I bet, that I have overlooked the obvious solution.


Best Regards,

Gerald
-------------- next part --------------
'From Haver 5.0 [latest update: #4997] on 6 December 2021 at 7:22:05 pm'!

!SocketStream methodsFor: 'stream in' stamp: 'KLG 12/6/2021 19:19:14'!
nextReceivable
	"Answer all the data currently receivable,
	in buffer and in socket.
	Block if there is now data receivable."

	"Receive available data, as we want to answer as much data as possible."
	self receiveAvailableData.
	"Block, to avoid any busy loops."
	self isInBufferEmpty ifTrue: [ self receiveData ].
	^ self nextAllInBuffer! !


More information about the Cuis-dev mailing list