WTSupported in traditional Synergy on Windows
WNSupported in Synergy .NET on Windows
USupported on UNIX
VSupported on OpenVMS
status = %SS2_GETADDRINFO(h_name, in_addr6)
If successful, returns SS_SUCCESS (0). If unsuccessful, returns SS_ENULL (2). See the Socket Errors table for additional information about this error. (n)
Specifies the host name. (a)
Returned with the IPv4 or IPv6 address(es). ([#][#]byte)
%SS2_GETADDRINFO retrieves an IP address using the host name in h_name as a search parameter. Since the in_addr6 argument is a dynamic array (of a dynamic array of bytes), it will create as many arrays as needed and fill them with all of the IP addresses associated with the host name.
This function supports both IPv4 and IPv6 formatted IP addresses. When retrieving addresses from the byte array, you can tell whether they are IPv4 format or IPv6 format by the length: IPv4 will be 4 and IPv6 will be 16. See the example below.
If SS_ENULL is returned, the system error code can be returned by immediately calling %SYSERR.
Do not use %SS2_GETADDRINFO to resolve IP address strings—it should be used only when the known value is the host name. To resolve an IP address string, use %SS2_INET_PTON to convert the string to a numeric IP address. If you want to get the host name, you can then use %SS2_GETNAMEINFO to retrieve that value.
This example shows how to get an array of IP addresses associated with www.mywebsite.com and loop through them to extract the IPv4 and IPv6 addresses for processing.
record status ,i4 addrArray, ,[#][#]byte numEntries ,i4 len ,i4 i ,i4 proc status = %ss2_getaddrinfo("www.mywebsite.com", addrArray) numEntries=addrArray.length ; get number of entries in array for i=1 step 1 until numEntries do ; loop through the entries begin len = addrArray[i].length ; get the length of each address if len = 4 then ; IPv4 addresses ; do some processing here else if len = 16 ; IPv6 addresses ;do some different processing here end