I had a similar issue when implementing a TCP server for logging
incoming socket connections. I contacted Intersystems and they informed
me that Cache 5.1 (and later) has additional features in this area.
Since I am running off Cache 5.0.18 this wasn't of much use. They gave
me a bit of code to try out, and it worked perfectly for what I needed.
Below is my code. It waits for a TCP socket connection and upon
receiving one identifies the IP address. The key function in this is
$zu (It then has to be formatted). I know this isn't exactly what you
are looking for, but perhaps it will help. This also works with Cache
5.1 and later, but the additional functionality is supposed to be more
robust and easier to use. I would contact Intersystems regarding that
functionality.
use tcp s aip=$zu(111,0)
s vClientIP=$a(aip,1)_"."_$a(aip,2)_"."_$a(aip,3)_"."_$a(aip,4)
use 0 w "["_$ZDT($h)_"] Connection Established From: "_$g(vClientIP),!