From: ian@... Date: 2008-01-05T06:34:59+09:00 Subject: Re: problem with sockets On 4 Jan, 15:35, James Tucker wrote: > On 4 Jan 2008, at 11:14, Francis Cianfrocca wrote: > > > > > ------=_Part_26026_29096075.1199459699490 > > Content-Type: text/plain; charset=ISO-8859-1 > > Content-Transfer-Encoding: 7bit > > Content-Disposition: inline > > > On Jan 4, 2008 10:01 AM, James Tucker wrote: > > >> STDIN.gets blocks hard on windows - that is, it blocks at the "c > >> level" which blocks all running green threads. > > >> The result is this 'lag' behavior - in fact what is happening > >> normally > >> is that you're not getting any running threads or socket reads except > >> in the time between gets returning a value, and being called again. > > >> If you avoid $stdin, you will find that the flow is smooth. > > >> Oh, and $stdout blocks too... > > >> There's a video here that sort of demonstrates this in a visual way: > > >>http://blog.ra66i.org/wp-content/network_rotator_fun.swf > > >> One side is an echo server, which reverses the string it echos, and > >> the other is a generator, which generates strings with a moving # in > >> them. "I" and "O" have meaning local to the respective application. > >> The right hand side is the generator, the left hand side is the > >> reversing echo server. > > >> Those were actually built on top of EM, but it's the same issue you > >> see. > > > The generic answer that EM would provide is: "don't use threads at > > all." > > The video there doesn't use threads. That's a completely "native" EM > stack that uses the protocol code I showed you a few weeks ago. In > fact, it's the demo application I'll be releasing with that protocol. > > With or without threads, the problem the OP was describing actually > comes up anyway on Windows, as the console IO code could really do > with being made non-blocking, like it is on *nix. My understanding is > though, that this is non-trivial. > > > Unfortunately, at the current time, there is a problem in EM's console > > handler that makes event-driven keyboard input unre > > lol, :-) - Is that me or you, or a joke? (the premature termination). > > Hmm, Luis got it, looks like it was me, scary. *slaps* Mail.app. Hi thanks for the answers. I removed the stdin line and replaced it with gets, and it still has the same error. Can I take it Ruby Sockets don't work very well with windows? Big disadvantage if that's true, as it's so often compared to Java, and it's claimed that it's multi platform. I'm not sure what all the "EM" stuff means, is that some windows thing? Thanks again, but I'm still non the wiser Ian