Two clients in capnp

51 views
Skip to first unread message

Omega Ishendra

unread,
Dec 23, 2018, 11:47:23 PM12/23/18
to Cap'n Proto
Hello world,

I am new to capnp. I want to know whether we can implement two servers in capnp.
The requirement is to reduce number of polling in the communication. If we have a client, it seems to be we have to poll many times, which can affect runtime.
Is there anyway I can acheive this.
Are there ant example codes available?

Thanks

Kenton Varda

unread,
Dec 24, 2018, 3:39:29 PM12/24/18
to Omega Ishendra, Cap'n Proto
Hi Omega,

Sorry, I don't understand your question.

Cap'n Proto RPC uses an event loop concurrency model. "Polling"
shouldn't ever be necessary.

-Kenton
> --
> You received this message because you are subscribed to the Google Groups "Cap'n Proto" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to capnproto+...@googlegroups.com.
> Visit this group at https://groups.google.com/group/capnproto.

Omega Ishendra

unread,
Dec 25, 2018, 11:32:14 PM12/25/18
to Cap'n Proto
Sorry for the unclearness.

In short what I want to know is,

I know that we can have multiple clients.
Can we have two severs in capnp?
If it is yes, Is there any example code available which I can refer?


Thanks,
Omega

Kenton Varda

unread,
Dec 27, 2018, 1:40:54 PM12/27/18
to Omega Ishendra, Cap'n Proto
Yes, you can have as many servers as you want. In fact, once connected, Cap'n Proto doesn't know the difference between a client and a server -- either side can send messages to the other equally. Cap'n Proto is designed as a peer-to-peer protocol; any notion of client or server happens at the application level.

The only catch here is that sometimes people write Cap'n Proto "client" code by calling promise.wait() to synchronously wait for promises to complete. When you have multiple calls happening concurrently (as you would when there are multiple servers), you can't do that -- you have to use .then() to register callbacks to call when the promise completes. (This applies to the C++ library -- the details may be a bit different in other languages.)

-Kenton
Reply all
Reply to author
Forward
0 new messages