soAddrLookup (Function)

Top  Previous  Next

Architecture:

NX32L

Device support:

All

Firmware version:

1.08.00


Resolve an IP address, like "80.62.33.111", or a symbolic name, like "domain.com", to a socket address.

 

 

Input:

str : STRING

IP address (in dotted format "aaa.bbb.ccc.ddd" or symbolic "domain.xyz").

 

iface : SINT (default 0)

The network interface to use. 0 = Default, 1 = Mobile network, 2 = LAN network, etc. (See Network)

 

 

Output:

address : STRING

The socket address.

 

 

Returns: INT

1

- Success.

0

- The function is not supported.

-2

- One or more parameters are illegal.

-17

- Generic error.

 

Declaration:

FUNCTION soAddrLookup : INT;
VAR_INPUT
  str     : STRING;
  iface   : SINT := 0;
  address : ACCESS STRING;
END_VAR;

 

 


Example:

 

INCLUDE rtcu.inc
 
PROGRAM example;
VAR
address : STRING;
port    : DINT;
host    : STRING;
rc      : INT;
END_VAR;
 
netOpen(iface := 2);
 
BEGIN
  ...
// Look up address
rc := soAddrLookup(str := "www.example.com", iface := 2, address := address);
DebugFmt(message := "soAddrLookup   = \1", v1 := rc);
 
// Show address
soAddrInetGet(address := address, host := host, port := port);
DebugMsg(message := "    IP address = " + host);
  ...
END;
END_PROGRAM;