> Hi,

Hello

> I was wondering if anyone knew the answer to two questions:
> 
> 1) Can I use more than one KATCP connection within one process?

Yes. See kcppar for an example which issues commands to 
multiple katcp servers in parallel. 

> 2) If so, do they need to be protected from each other via mutex?

That depends. 

Each katcp client connection keeps it state a handle/state 
structure (katcl_line) - so there shouldn't be global variables 
to be overwritten.

This means where you use select() on multiple connections
or only use a connection per thread you should be fine. However,
access to individual data structures isn't locked - thus if you
access the same data structure from multiple threads you will
need to provide your own mutexes.

[Personally I find that threads make reasoning about code
quite a bit harder, and thus prefer to use select() or poll()
for doing concurrent IO, even if the initial effort is a bit more]

regards

marc

Reply via email to