Hi everyone,is there a way to tell clients written in c++ that somethings happenedon the kdb+ server ?Imagine i have got a table called parameters on the kdb+ server. Eachtime the table has changed i want to notify every clients that has aconnection to this server. How can i do this?I know that one can use the function sd1(d,f) to register callbackfunctions in kdb+.Can i solve this problem with the sd1 function?Is there an example?Thanks for any comments or answerKim
https://code.kx.com/trac/wiki/Reference/dotzdotvs
Inside .z.vs send an async msg to each client that is interested in changes.
On the c++ side, just listen for changes with
**int** c = khpu( **"localhost"** , 1234, **"myusername:mypassword"** );_// Connect to a Kdb+ server on the localhost port 1234 ._r = k(c,(S)0);_// read incoming async_
Hi Charles,
thx for your quick answer.
But still have problems to understand the code snippet on the client
side.
Using the code:
K r = k(c,(S) 0);
i got a variable called r.
What should i do with r know?
Should i put r in a loop to test for changes?
What should i do when i want to get notified?
No callbacks?
Hi Charles,
I tried the solution on my laptop and it works. Not bad.
what is the use case for the sd1 function then?
Sent from my iPhone
It’s documented on https://code.kx.com/trac/wiki/Cookbook/InterfacingWithC
CCallbacks
The void sd0(I); and K sd1(I, K(*)(I)); functions are for use with callbacks and are available only within kdb+ itself, i.e. used from a shared library loaded into kdb+.
**sd1** (d,f);
Puts the function K f(I d){..} on the q mainloop given a socket d (or -d for nonblocking). The function f should return (K)0 or a pointer to a kobject and its reference count will be decremented.
sd0(d);
Removes the callback on that socket.