Tried this on RB1000 with 5.0rc10
first, separate commands, removed quotation from =contents="some text" as that is not required to be there in rsc file.
 wanted to add a bit about the protocol and how this works.
so you send in length and string, that in this case is formed this way:
API will read length, if it is not too long, it will read the string and see that argument is =contents= the rest of the string is value for the argument. Because of all this, you can set contents to whatever you like, even if you set it to "= contents=" it will be no concern for API.
Same thing happens when API returns some stuff, like script, you get =source=<whole script>
second ran it some other C++ code that did these commands
$ time ./TestAPI ret: !done ret: !done ret: !done ret: !done real 0m0.270s user 0m0.000s sys 0m0.000s
p.s. since i am paranoid of sorts, did not run your code.