Mac - Computer Name - Omnis 11.1 - OS Sequoia

Kelly Burgess kellyb at montana.com
Fri Oct 4 10:47:58 UTC 2024


Mike wrote:
>It looks like to me that " TCPGetMyAddr" and " TCPName2Addr " are not working on Mac.

Joe pointed out a subtle thing about TCPGetMyAddr.  You get different results in different situations.  If you use a socket that's created but not connected to anything, you'll get 0.0.0.0.  If you use a socket that's connected to a server like Joe illustrated, you'll get the proper LAN address of the machine hosting Omnis. (10.0.0.11 in my case)

With TCPName2Addr it's emulating a DNS lookup.  When passed the 'sharing name' of the machine, it will give you an APIPA self-assigned IP 169.254.xxx.  When passed an unrecognized name, it returns a simple 0.  When passed a dotted IP address, it returns the same dotted IP.

-------------------------------------------------  (tested with Studio 10.22 and 11.1 on a Mac)
    TCPSocket Returns sock
    TCPGetMyAddr (sock,kFalse) Returns addr1
    TCPClose (sock,0)

    TCPConnect ('www.google.com',80) Returns sock
    TCPGetMyAddr (sock,kFalse) Returns addr2
    TCPClose (sock,0)

    TCPName2Addr ('localhost') Returns addr3
    TCPName2Addr ('MacPro.local') Returns addr4
    TCPName2Addr ('www.google.com') Returns addr5

    Breakpoint [addr1] -- [addr2] -- [addr3] -- [addr4] -- [addr5]

0.0.0.0 -- 10.0.0.11 -- 127.0.0.1 -- 169.254.121.115 -- 142.251.215.228

-------------------------------------------------

My TCPTools xcomp has the $interfacelist() method that Doug described. (I've also put that function in my UniqueID xcomp.)  TCPTools is a collection of some old TCPTalk utility commands that got ported to an xcomp.  TCPTalk itself never made it to 64bits, because by that time, Omnis had those bases covered for the most part.

    Calculate iInterfaceList as TCPTools.$interfacelist()
    Do iInterfaceList.$sort($ref.type,kFalse,$ref.name,kFalse)

  type           address                          name
===========================================================
AF_INET        192.168.75.1                     bridge100
AF_INET        172.16.223.1                     bridge101
AF_INET        10.0.0.11                        en1
AF_INET        169.254.121.115                  en10
AF_INET        169.254.131.85                   en9
AF_INET6       fe80::e450:ebff:fe9b:ea64        bridge100
AF_INET6       fe80::e450:ebff:fe9b:ea65        bridge101
AF_INET6       fe80::1ce9:f13a:560d:8b70        en1
AF_INET6       fe80::181b:6d36:d050:3d29        en10
AF_INET6       fe80::aede:48ff:fe00:1122        en8
AF_INET6       fe80::10ac:a471:1265:3577        en9
AF_INET6       fe80::c2c6:5158:ff2f:90fe        utun0
AF_INET6       fe80::a175:43c1:d95d:3cb9        utun1
AF_INET6       fe80::ce81:b1c:bd2c:69e          utun2
AF_LINK        02:a1:d8:c1:90:09                bridge0
AF_LINK        e6:50:eb:9b:ea:64                bridge100
AF_LINK        e6:50:eb:9b:ea:65                bridge101
AF_LINK        e4:50:eb:b9:db:57                en0
AF_LINK        e4:50:eb:bb:b8:ff                en1
AF_LINK        26:ee:b8:6c:fa:4f                en10
AF_LINK        f8:ff:c2:0d:a3:93                en2
AF_LINK        02:a1:d8:c1:90:09                en3
AF_LINK        02:a1:d8:c1:90:08                en4
AF_LINK        02:a1:d8:c1:90:0d                en5
AF_LINK        02:a1:d8:c1:90:0c                en6
AF_LINK        ac:de:48:00:11:22                en8
AF_LINK        c6:2a:d0:97:55:45                en9
AF_LINK        02:51:c5:f8:d4:8f                llw0
AF_LINK                                         utun0
AF_LINK                                         utun1
AF_LINK                                         utun2
AF_LINK        86:b5:28:57:86:01                vmenet0
AF_LINK        9a:18:b7:c5:71:71                vmenet1
AF_LINK        9e:53:a4:f6:1b:33                vmenet2

It's worth pointing out that Joe mentioned looking for an IP matching the en0 interface obtained from some other script, and that *could* be a problem, as illustrated above.  I've got a MacPro that has two ethernet connectors, and I just happened to plug the cable into the one for en1, leaving en0 unconnected, so this machine has ethernet connected but en0 ain't it... so, word of caution there.

Kelly


More information about the omnisdev-en mailing list