Skip to content
Jaskirat Rajasansir edited this page Jun 16, 2022 · 6 revisions

Inter-Process Communication Library

This library provides connection management and tracking when communicating with other kdb+ processes.

.ipc.connect / .ipc.connectWait / .ipc.connectWithTimeout

This functions accept a 'host/port' type target and attempts to connect with varying connection timeouts:

  • .ipc.connect: Will use a connection timeout of .ipc.cfg.defaultConnectTimeout (5 seconds by default)
  • .ipc.connectWait: Will wait indefinitely
  • .ipc.connectWithTimeout: Will wait the specified number of milliseconds

.ipc.connectWithHp

This function accepts a separate 'host' and 'port' argument and builds the 'host/port' type before calling .ipc.connect.

Outbound Connection Tracking

By using the included .ipc.connect* and .ipc.disconnect functions, all successful connections will be logged in the .ipc.outbound table.

Example

q) .ipc.connect 12345
Attempting to connect to 12345 (timeout 5000 ms)
Successfully connected to 12345 on handle 480
480i

q) .ipc.outbound
handle| targetHostPort connectTime
------| --------------------------------------------
480   | ::12345        2017.03.31D10:16:31.440579000

Inbound Connection Tracking

Inbound connection tracking is optional and can be configured by changing the .ipc.cfg.enableInboundConnTracking boolean.

If enabled, the Event Management library will be loaded to allow it to listen to inbound port and websocket open / close events.

All inbound connections will be stored in .ipc.inbound.

Example

Notifying listeners of event [ Event: websocket.open ] [ Args: 496i ]
New inbound websocket connection on handle 496 [ IP Address: 127.0.0.1 ] [ User: unknown ]
Notifying listeners of event [ Event: port.open ] [ Args: 492i ]
New inbound kdb connection on handle 492 [ IP Address: 127.0.0.1 ] [ User: jasra_000 ]

q).ipc.inbound
handle| sourceIp  user      connectTime                   connectType
------| -------------------------------------------------------------
496   | 127.0.0.1 unknown   2017.03.31D10:35:51.783433000 websocket
492   | 127.0.0.1 jasra_000 2017.03.31D10:35:55.109387000 kdb
Notifying listeners of event [ Event: port.close ] [ Args: 296i ]
Inbound connection on handle 296 closed [ IP Address: 127.0.0.1 ] [ User: jasra_000 ]

q) .ipc.inbound
handle| sourceIp user connectTime
------| -------------------------

By default, if a password is specified in the host/port, the password component will be switched to asterisks for logging and for adding into .ipc.outbound.

This behaviour can be changed via .ipc.cfg.logPasswordsDuringConnect.

Clone this wiki locally