Threading / sockets bug

K

kingsley

Where do I report this bug?

Only happens on windows platform:

causes some error ot lock that doesnt occur on Unices

require \'socket\'
require \'thread\'

sock = TCPSocket.new(\'ancient.anguish.org\',2222) # login name is :
guest (no password needed)

t1 = Thread.new do
if line = gets
sock.write line
end
end

t2 = Thread.new do
loop do
ch = sock.recv(1)
putc ch
end
end

t1.join
t2.join

Thanks

Kingsley
 
S

Shashank Date

Where do I report this bug?

Only happens on windows platform:

I don't think it is a bug ... just a limitation of light-weight threading
on windows.

Try this (it worked for me using ruby 1.8.0 (2003-06-23) [i386-mswin32]
on Win XP Pro):

# ------------------------------------------------------
require 'socket'
require 'thread'

sock = TCPSocket.new('ancient.anguish.org',2222)
# login name is : guest (no password needed)

t1 = Thread.new {
if line = gets
sock.write line
end
}

sleep(0.01) #<------- added this line

t2 = Thread.new {
loop do
ch = sock.recv(1)
putc ch
end
}

t1.join
t2.join
# ------------------------------------------------------

HTH,
-- shanko
 

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

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top