Aw init bind

From ActiveWiki
Jump to: navigation, search


Minimum requirements
Added in version 4.1
SDKbuild 61


int aw_init_bind (int build, unsigned long addr)

Description

Initializes the SDK and specifies the source IP address for outbound connections.

Callback

None (returns immediately)

Notes

Specifying the source IP address is useful when you have multiple network interface cards (NIC) or a single NIC with multiple IP addresses. The source IP address must either match or be within range of the IP address(es) used by a network interface on the system.

This method or aw_init must be called once before any other methods in the API. It will do an implicit aw_term if the SDK has already been successfully initialized. Thus, there is no need to call aw_term for each additional call to this method, as there is no reference count.

If successful then the tick count returned by aw_tick is reset to 0 and the pseudo-random number generator used by aw_random is seeded.

Arguments

build
AW_BUILD in Aw.h defines the build of Aw.dll (or libaw_sdk.so for Linux) it was distributed with and should be passed as the value of this argument.
addr
Source IP address for outbound connections (in network byte order.) If set to 0 (0.0.0.0) then it will be the same as calling aw_wait.

Argument attributes

None

Return values

RC_SUCCESS
RC_VERSION_MISMATCH
Aw.h and Aw.dll (or libaw_sdk.so for Linux) are from different builds of the SDK.

Returned attributes

None

Usage

#include "Aw.h"
#include "Reason.h"

int main (int argc, char *argv[])
{
  /* use 192.168.0.1 as the source for outbound connections */
  if (aw_init_bind (AW_BUILD, inet_addr ("192.168.0.1")) != RC_SUCCESS)
  {
    printf ("Build #%d of Aw.dll is required to run this bot.\n", AW_BUILD);
    return 1;
  }
  
  /* ... */
  
  aw_term ();
  return 0;
}

See also