Re: String Matching Problem



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/

.



Relevant Pages

  • Algorithm for reading from continuous stream
    ... I don't have much experience with reading from continuous stream (I ... about variable sized packets from the socket? ... After reading in the 1st time, and processing, I'm sure to have left ... over bytes and the end of the buffer. ...
    (comp.programming)
  • CAsyncSocket -> OnReceive -> Receive does not remove data in the queue?
    ... I have data that is send from on socket to another. ... As per the documentation, for every OnReceive(... ... I then handle the buffer of data, I read 8 bytes of data and that ... In other words I am reading the same 4096 bytes again. ...
    (microsoft.public.vc.mfc)
  • Re: client-server using named pipes
    ... network socket and writes that data to a named pipe, ... we read the message from the client into a buffer. ... of reading to a buffer, i want to read the message directly into the ...
    (comp.unix.programmer)
  • Reading bytes from a socket
    ... I have a problem while reading bytes from a socket. ... it seems that the buffer maximum size is 8192 bytes. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Discovering variable types...
    ... >memory it points to is on the heap. ... sequentially reading data, if one is randomly reading records, then a ... >project is what's prompting me to improve disk access. ... from a memory buffer I can do it in about a second. ...
    (comp.lang.pascal.delphi.misc)