Back to Synchronous & Asynchronous Requests

Interprocess Communication (IPC) · Synchronous & Asynchronous Requests · Practice Question

Insert Data into a Remote Table, Sync and Async

Sign in to track your progress

Question

On the client process, create a simple table:

t:([] sym:`symbol$(); price:`float$())

On the server, open a connection to the client and send data into t using both a synchronous and an asynchronous request. Confirm on the client that the table was populated.

Solution

On the server:

q)clientH:hopen 5002
q)clientH(insert;`t;(`A`B;10 20f))
0 1
q)neg[clientH](insert;`t;(`C`D;30 40f))

On the client:

q)t
sym price
---------
A   10
B   20
C   30
D   40

Explanation

clientH(insert;`t;(`A`B;10 20f)) sends a synchronous functional request — the server blocks until the client runs insert[`t;(`A`B;10 20f)] and returns a result (0 1, the new row indexes).

neg[clientH](insert;`t;(`C`D;30 40f)) sends the same request asynchronously — negating the handle skips waiting for a reply, and the server moves on immediately.

Both use the same (function;arg1;arg2;...) structure; only the handle's sign differs. Either way, t on the client ends up with both sets of rows.