Connection Handle

<< Click to Display Table of Contents >>

Navigation:  NmxDLL Referenz > API (programming interface) >

Connection Handle

The NMX DLL allows having multiple connections to different devices, even though in most applications one connection to one device is used.

In order to distinguish between multiple connections, a unique handle is assigned for each of them by the NMX DLL.

 

Technically spoken, a handle is nothing else than a pointer to an address space managed by the NMX DLL. This is a common programming technique.

The pointer itself resides outside the NMX DLL in the user application. It is assigned if a connection has been established successfully (see NMX_DeviceIPv4Open_1). It is then used in almost every DLL function, to identify the relevant connection. It is deleted by closing the connection (see NMX_DeviceClose_1).

 

The Handle has the following type definition (C-Code):

typedef void* NMX_PHANDLE;

 

For each connection a handle must be declared. In case only one connection is used, the declaration looks as follows:

NMX_PHANDLE pHandle = NULL;

 

Note for the .Net DLL: Using the .Net DLL, the handle uses the type System::IntPtr. The basic concept is the same. In case only one connection is used, the declaration in C# looks as follows:

IntPtr pDevice = IntPtr.Zero;

 

Further information, if you use multiple connections / handles:

Inside the NMX DLL, each connection / handle has its own memory and its own communication tasks. Talking in object orientated programming, a separate object is created for each handle.

If notifications are used, these must be registered for each handle separately.