in reply to Socket IO NO new line

I do not profess to have taken the time to “grok” your particular requirement completely, but the general flow of any such server is going to amount to this:

  1. The server, as a whole, is “waiting for input, then receiving and processing that input, then waiting for more input,” until the appropriate signal finally arrives that says that it should terminate.
  2. Each time the server has received more input, it should append that input to a buffer of some kind.
  3. Each time it does so, the server should check to see if the buffer contains “a complete input.” (In other words: “STX..something..ETX”) while it has this, it should remove the complete string from the buffer, process it, and check again to see if there is yet-another occurrence of “a complete input,” repeating this procedure until there are no more. It will therefore repeat this loop “zero or more” times following each successful read.

Each time the server “reads something from the input pipe,” it has no way to know if “a complete input” has arrived or not. Likewise, it doesn't know how many complete-inputs have arrived. But it can accumulate those readings into a buffer, then chomp zero-or-more “complete inputs” from that buffer as it discovers them.