SocketSteam: Switching ascii/binary modes

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

SocketSteam: Switching ascii/binary modes

Igor Stasenko
Hello,

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

binary
        "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
data.

What you think is an appropriate solution to this?

--
Best regards,
Igor Stasenko AKA sig.

_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project