Re: String Matching Problem
- From: Robert Klemme <shortcutter@xxxxxxxxxxxxxx>
- Date: Thu, 29 Oct 2009 12:02:41 -0500
2009/10/29 Matt Brooks <mattbrooks@xxxxxxxxxx>:
Hopefully that makes sense, It is a little complicated which is why
initially I didn't go into why I have a buffer and all...
Um, I have to say I'm a bit stumped. First of all, from your
explanation it is not clear to me about which of the two (?) processes
we are talking. It's easier (at least for me) if you use variables,
e.g. "I have a process A which opens a server socket. Process B
connects to A with 1 connection ... Process B is the one I implement
in Ruby and...".
Ideas on how to prevent my false positive situation when using line[cmd]
way?
Maybe. A few things strike me as odd:
- Several different threads seem to be reading from the same
connection. Not sure whether that's a good idea because that makes
synchronization necessary.
- Since several threads seem to be reading from the socket, any thread
may read another thread's answer which is why you need the buffer.
- No need to reach character by character until \n, you can use #each
or #gets for that which should be significantly faster.
I would start by only having one thread writing to the socket and one
thread reading from it. The writer reads messages from a queue where
they are placed by worker threads. How we connect the reader with the
worker threads so that each worker thread gets it's reply depends on
things that aren't clear to me yet.
Kind regards
robert
--
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/
.
- Follow-Ups:
- Re: String Matching Problem
- From: Matt Brooks
- Re: String Matching Problem
- References:
- String Matching Problem
- From: Matt Brooks
- Re: String Matching Problem
- From: Brian Candler
- Re: String Matching Problem
- From: Matt Brooks
- Re: String Matching Problem
- From: Robert Klemme
- Re: String Matching Problem
- From: Matt Brooks
- String Matching Problem
- Prev by Date: Re: Desktop GUI apps in Ruby
- Next by Date: Re: Desktop GUI apps in Ruby
- Previous by thread: Re: String Matching Problem
- Next by thread: Re: String Matching Problem
- Index(es):
Relevant Pages
|