hroyd hroyd wrote in post #993957:
> Hello
>
> First post (i am new to ruby :-)). Can you help?
>
> I am using eventmachine to read in TCP segments off the network. I read
> in a TCP segment that contains 4 messages. The TCP segment binary data
> is shown below, where
> \xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\ is the
> marker for each message. I would like to split the data intot he 4
> messages, but am having trouble doing so. When I split the data, the
> whole message gets inserted into the first array element.

I'm not seeing that.  Your message starts with the delimiter, so the 
first element of the array will be a blank string:

str = "\xFF\xFF" +
      "\x61" +
      "\xFF\xFF" +
      "\x62" +
      "\xFF\xFF" +
      "\x63" +
      "\xFF\xFF" +
      "\x64"

pattern = "\xFF\xFF"
p str.split(pattern)

--output:--
["", "a", "b", "c", "d"]

-- 
Posted via http://www.ruby-forum.com/.