Search code examples
kdb

User the kdb+ timer with an IPC handle


I'm trying to connect to an RDB from a client and get a row count for one of the tables every x seconds using the .z.ts timer function. So assuming my RDB is listening on port 5011 then my q code looks something like this:

h:hopen 5011

.z.ts:{h"count table"}[]

\t 1000

However, I get the following error showing the count returned can't be written to the handle as it's invalid...:

Cannot write to handle 183701. OS reports: The handle is invalid.

Any insight would be appreciated.


Solution

  • Because you're passing an empty argument to the lambda while defining .z.ts, you're just assigning .z.ts to be 'count table' and then when the timer ticks it tries to send the timestamp across whatever integer is stored in .z.ts which isn't a valid connection.

    Remove the empty argument and it'll work