views:

65

answers:

1

I have a nodejs TCP server and a client. Basic network communication happens. Client sends "data + STX_CHARACTER + data + ETX_CHARACTER" (just an example).

How do I split the string using the STX Control Character as a delimiter or how do I reference the character at all in Javascript.

+2  A: 

STX and ETX are characters 0x02 and 0x03 respectively, so it'd just be "\2" and "\3". Just use string.split("\2") and .split("\3") on the second chunk from the first split to get your data.

b0lt