[squeak-dev] SocketSteam: Switching ascii/binary modes

Igor Stasenko siguctua at gmail.com
Tue Mar 16 02:44:47 UTC 2010


it looks like its unsafe to switch between ascii/binary mode in SocketStream,
because it resets buffers upon switch:

	"Tell the SocketStream to send data
	as ByteArrays instead of Strings.
	Default is ascii."

	binary := true.
	self resetBuffers

The dynamic mode switching is useful:
for instance i want to read HTTP headers first, which is preferable to
do in ascii mode,
but its contents may be binary , which obviously preferable to read in
binary mode, to avoid
extra conversions.

Since SocketStream caching the data it reads, then instead of
resetting the buffers it should convert them and avoid losing the

What you think is an appropriate solution to this?

Best regards,
Igor Stasenko AKA sig.

More information about the Squeak-dev mailing list