Monday, May 31, 2010

ADS 10 Tip #1 – Finding Servers

A new API for locating all Advantage Servers on a network has been added. AdsFindServers uses multicast packets to discover all instances of Advantage running on the network. This new API can discover any version of Advantage.

The API has two options ADS_FS_MULTICAST_ONLY (0x01) and ADS_FS_CONNECT_ALL (0x02). The multicast only option retrieves the minimal information about the servers on the network which includes the IP address and Port number. Version 10 servers will also return the server name. When using connect all the API will attempt to connect to each server that is discovered returning more detailed information.

ADSHANDLE hTable;
UNSIGNED32 ulRet;

ulRet = AdsFindServers( ADS_FS_MULTICAST_ONLY, &hTable );
if ( ulRet == AE_SUCCESS )
  // Use the table handle to save or view the data

Since this is a new API it is only currently available via direct API calls. When the operation completes you receive a table handle which can be used to view the results. For example you could use the AdsCopyTable API to create a physical table containing the results, an example of this method is in the help file. You could also read the results from the table using the Advantage API calls.

No comments: