-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathipc_client.q
76 lines (55 loc) · 1.8 KB
/
ipc_client.q
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
// run this script after running ipc_server.q
// open a handle to the server process listening on port 1234
h:hopen 1234;
// show what socket the handle h has been assigned to
h;
// open a handle to the server process at localhost listening on port 1234 and specifying the host
h1:hopen `:localhost:1234;
h2:hopen `::1234;
h3:hopen("::1234")
// show all open client handles from current session
.z.W;
// close a connection
hclose h2;
// close a connection using its socket number
// hclose 5;
// open a connection to a server process with password protection
h2:hopen `:localhost:1234:Michael:password123;
// give a hopen request a timeout limit of 10 milliseconds
h4:hopen(":localhost:1234;10");
// send the expression 2+2 to the server
h1"2+2";
// send the expression 2+2 to the server in functional form using the handle number
// 3(+;2;2);
// define a variable g with value 42 on the server
h1"g:42";
// define a variable h with value 24 in functional form on the server
h1(set;`g;24);
// use a function f defined on the server that takes one integer parameter
h1"f[2]";
h1(`f;4);
h1("f";8);
// write a function on the client and execute it on the server
f2:{x - y};
h1(f2;3;4);
// get the list list1 from the server
h1(get;`list1);
// send the expression 2*2 to the server asynchronously
(neg h1)"2*2";
// run a function defined on the server asynchronously
(neg h)(`f;4)
// define a list on the server asynchronously
(neg h1)"list2:4 2 4 2"
// to ensure that all async messages have been processed
// chase with a sync message
h1"";
// flush the queue
(neg h1)[];
// or
neg[h1](::)
// show a message on the server eight times every three seconds
f:{show .z.p}
flush2:{(neg h)(f;`);(neg h)[];now:.z.p;while[.z.p<now+0D00:00:03;()]
do[8;flush2[]]
// ensure an async message has been sent immediately
neg[h1]x; neg[h][];