Gents,
First, thank you all for your time and quick responses. I am beginning
to see why people are flocking to ruby besides the language itself and
the RoR framework. It is the wonderful community help eco-system
surrounding it. May be with your help, I can come up to speed and start
helping others.
Second, you are right. I am running it from SciTe. In Linux world, I
am more comfortable at the shell prompt and open up a number of shell
windows. Moreover, I am always editing with either vim or sometimes
gedit and as a result, running the ruby programs from the command
prompt. That has to be the reason why I haven't run into these kinds of
obscure problems yet, especially dealing with standard input/output.
I ran the program from the command prompt and it waits for my input and
I can type on the terminal as much as I want. However, I don't know how
to signal the termination of the standard input. I tried CTRL-C which
is obviously the termination of the program. since I see that in the
stack trace as follows:
ex0261.rb:7:in `read': Interrupt
from ex0261.rb:7
The seventh line of the code in the program above is:
while data = socket.read(1)
Chris, as you suggested, I changed the buffer count to 1 instead of 512,
but still no go. I type the text and hit the enter key but windows just
waits for me to enter text. I guess it boils down to generating end of
the input signal to windows. In unix/linux it is CTRL-D, which does not
work in windows.
Wolfgang, you wrote:
"the shebang will NOT work in a windows environment at all."
You mean in: $stderr.print "IO failed: " + $!
right? Is there any other way I can write something which works in both
Windows and Linux in a cross-platform manner?
Thanks again and regards to you all.
Bharat
--
Posted via http://www.ruby-forum.com/.