windows help/pipes/thread

A

Ara.T.Howard

can someone tell me the behaviour of these two programs run in separate
terminals under windows?

harp:~ > cat a.rb
system "mkfifo fifo >/dev/null 2>&1" # don't know how to do this in win
File::chmod 0777, "fifo"

t0 =
Thread::new do
loop do
open("fifo", File::RDONLY|File::NONBLOCK) do |fifo|
f = select([fifo]).first.first
STDERR.print f.read
end
end
end

t1 =
Thread::new do
loop do
STDERR.puts 42
sleep 0.42
end
end

gets


harp:~ > cat b.rb
loop do
open("fifo", File::WRONLY) do |f|
f.puts 'forty-two'
end
sleep 0.42
end


i expect the output to look something like:

42
42
42
42
42
forty-two
42
forty-two
42
forty-two
42
forty-two
...
...


cheers.

-a
--
===============================================================================
| email :: ara [dot] t [dot] howard [at] noaa [dot] gov
| phone :: 303.497.6469
| Your life dwells amoung the causes of death
| Like a lamp standing in a strong breeze. --Nagarjuna
===============================================================================
 
A

Ara.T.Howard

A possible suggestion:
Maybe use sockets?

happen to be reading about that now... ;-)

the thing with pipes is testing can be done like

~ > cat test_stdin > pipe

which is __extremely__ handy for testing.

-a
--
===============================================================================
| email :: ara [dot] t [dot] howard [at] noaa [dot] gov
| phone :: 303.497.6469
| Your life dwells amoung the causes of death
| Like a lamp standing in a strong breeze. --Nagarjuna
===============================================================================
 
C

christophe.poucet

What you could do is make a simple program "pipe" that forwards to the
given socket.

Then you could do something like.

cat test_stdin | pipe localhost 1234
 
R

Robert Klemme

What you could do is make a simple program "pipe" that forwards to the
given socket.

Then you could do something like.

cat test_stdin | pipe localhost 1234

s/pipe/telnet/ - works even on Windows boxes. :) And while we're at it,
then you should also be able to do

telnet localhost 1234 < test_stdin

Ha, killed another useless cat! :)

Kind regards

robert
 
A

Ara.T.Howard

What you could do is make a simple program "pipe" that forwards to the
given socket.

Then you could do something like.

cat test_stdin | pipe localhost 1234

i guess the idea is out since windows does not support AF_LOCAL ;-( tcp would
be __way__ too slow.

-a
--
===============================================================================
| email :: ara [dot] t [dot] howard [at] noaa [dot] gov
| phone :: 303.497.6469
| Your life dwells amoung the causes of death
| Like a lamp standing in a strong breeze. --Nagarjuna
===============================================================================
 
C

Charles Leeds

Hmm. Appears this isn't base Ruby functionality. My bad. I will have
to learn how to implement Nano in Rails.
 
T

Trans

You mean String#center.

True. #align_center is a Nano method. It differs from the built-in
#center in that it will center each line of a string (or any split for
that matter), not just the whole string as a single unit.

BTW, I thought it would be better if #center embraced this
functionality too, so I put in an RCR for it, but haven't yet heard if
it will be accepted.

http://www.rcrchive.net/rcr/show/313

T.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

[ANN] nbfifo-0.0.0 - non blocking fifos for threads 0
[ANN] open4-0.7.0 0
[ANN] open4-0.6.0 0
[ANN] open4-0.5.0 0
thread gurus please help... 7
[ANN] open4-0.9.2 0
[ANN] open4-0.8.0 2
[ANN] open4-0.9.0 0

Members online

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,813
Latest member
lawrwtwinkle111

Latest Threads

Top