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
ObjectScriptObjectScript
The IP address of the client can be obtained by:
set ip=##CLASS(%SYS.ProcessQuery).Open("P"_$j).ClientIPAddress
ObjectScriptObjectScript
* If the server and client are the same, the IP address obtained above will be 127.0.0.1.
Where I've used that second option to get an IP address, I've noticed that if the client has more than one IP address, it can return different ones different times, and I'm not sure how it determines which one.
It seems to be an IP of its first network adapter, probably of virtual one.
Hiroshi,
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)_"*" *MYPC* w ##CLASS(%SYS.ProcessQuery).Open("P"_$j).ClientNodeName ; prefered (documented) way MYPC w ##CLASS(%SYS.ProcessQuery).Open("P"_$j).ClientIPAddress 10.8.3.37
Alternative program which supports CacheActiveX connection showed the same results, by the way, regardless of server's platform, whether it was UNIX/Linux or Windows.
while results were similar in all previous Cache/IRIS versions I managed to run.
I should check docs before any "quick testing": only terminal (TRM:), telnet and file current devices can provide $ZIO with non-empty values. No client/server!
Thanks for pointing that out.
Certainly this method does not give us the answers we are currently expecting.
This article was originally posted in Japan quite some time ago, so it certainly would have worked in past versions.
Anyway, I will try to rewrite this article so that it works as expected in the latest version.
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: https://cedocs.intersystems.com/documentation/cache/cache41/olr/olrvzio....
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!