· Mar 15 1m read

How to get client IP or machine name

InterSystems FAQ rubric

When connecting to the database using a client-server architecture, for example using language binding, the machine name of the client can be obtained using the following code:

set client=##CLASS(%SYS.ProcessQuery).Open("P"_$j).ClientNodeName

The IP address of the client can be obtained by:

set ip=##CLASS(%SYS.ProcessQuery).Open("P"_$j).ClientIPAddress

* If the server and client are the same, the IP address obtained above will be

Discussion (6)2
Log in or sign up to continue

May I ask you where did it ever work?

Here are the results of quick test in Studio Output window: 

w "*"_$zio_"*"
w "*"_$zutil(67,12,$j)_"*"
w ##CLASS(%SYS.ProcessQuery).Open("P"_$j).ClientNodeName ; prefered (documented) way
w ##CLASS(%SYS.ProcessQuery).Open("P"_$j).ClientIPAddress

Alternative program which supports CacheActiveX connection showed the same results, by the way, regardless of server's platformwhether it was UNIX/Linux or Windows.

IRIS for Windows (x86-64) 2021.1 (Build 215U) Wed Jun 9 2021 09:39:22 EDT

while results were similar in all previous Cache/IRIS versions I managed to run.

Hiroshi, take it easy - everybody can make a mistake.
Meanwhile, I'm sure that $ZIO was initially intendent for terminal devices only. Here is the oldest link I was able to find:
Why not use ##CLASS(%SYS.ProcessQuery) for similar purposes? It's more powerful and better documented than some "mystic" system variables and functions.
Happy writing!