[zeromq-dev] Code-style question
Marco Trapanese
marcotrapanese at gmail.com
Wed May 23 13:42:49 CEST 2012
Il 23/05/2012 13:32, Andrew Hume ha scritto:
> as you point out, "commands" are different from "data".
>
> in my world, we are all using identical intel hardware/software, so data
> is sent as C structs.
>
> commands are different. the time spent parsing/generating commands is
> almost unmeasurably small,
> so i hew to Plan 9 style and simply send blank-delimited words.
> i use a very efficient field splitter, and then use strcmp, as in
>
> nf = split(msg, f, " ");
> if(nf < 1) return;
> if(strcmp(f[0], "func1") == 0){
> func1(strtol(f[1], 10, 0), f[2]);
> } else if(strcmp(f[0], "func2") == 0){
> so on ...
> } else {
> // rats; complain
> }
>
> its not terribly elegant, but it is straightforward and easy to maintain.
> and having regular text makes it easier to manually scan and debug.
> i have used something like JSON before, but it seemed like a lot of
> unnecessary work.
Thanks for you hints!
Marco
More information about the zeromq-dev
mailing list