STDIN Blocking- Why does it wait for CR?

BlitzMax Forums/BlitzMax Programming/STDIN Blocking- Why does it wait for CR?

Damien Sturdy(Posted 2008) [#1]
Just for kicks I have written a little personal "quote of the day" thing for my workmates.

I chose not to bother installing/configuring pre-existing plugins and wrote my script parser in BlitzMax.

PROBLEM: STDIN blocks until a carriage return is recieved. Why is this?

input() could be coded seperately, STDIN itself could really do with a method to tell if there is anything coming in, and if so, how many chars there are, in order to prevent the system from blocking.

the system blocks because as stated in the CGI 1.1 spec, the browser is NOT obliged to send a carriage return after the bytes are set.

Any ideas what I can do here?


Koriolis(Posted 2008) [#2]
I guess you are using StandardIOStream, right? Well surprisingly enough, you shouldn't use it for reading byte based data. StandardIOStream is wrapped with a TTextStream, which will cayse all nasty thins if you use this to read raw data (by example doing ReadByte won't read a single byte at all : it will read a text line and try to convert it to an integer). What you should do is instanciate a new TCStandardIO and use that instead of StandardIOStream.


Damien Sturdy(Posted 2008) [#3]
Ah! Well, I got around my issue another way, but I am very interested in this. How exactly would I do it if you don't mind me asking?

Thanks. :-)


Koriolis(Posted 2008) [#4]
Global gMyStdIO:TCStandardIO  = New TCStandardIO

Use gMyStdIO everywhere you previously used StandardIOStream.


Damien Sturdy(Posted 2008) [#5]
Easy enough. Thanks! I'll toy with it. :-)