Overview
The EVAPI_Discover function is used to test the connection between evAPI and an exacqVision server. When EVAPI_Discover is called, it initiates a Discover request to be sent to an exacqVision server. If the Discover request is received by the server, it sends a Discover response indicating the server was found.
<br>
Usage
It is possible to use the EVAPI_Discover function to detect the connection to an exacqVision server after a logged-in connection has been established with a server. Before a logged in-connection is established, the response from EVAPI_Connect and EVAPI_Login should be used to determine the server connection.
Before calling EVAPI_Discover, it is necessary to set an EVAPI_Callback function that handles the Discover response from the server. If no callback is defined or if ParamType Discover is not handled in the callback, the Discover response from the server is not seen.
The behavior of the EVAPI_Discover function is to queue a Discover request packet in an evAPI instance’s write buffer to be sent to the exacqVision server. If the write buffer has space for the Discover request packet, it return a 0 to indicate success. If the write buffer has filled up because evAPI has not been able to send any data or the write buffer is not being flushed, the function returns a 1 to indicate failure.
To send the Discover request, the EVAPI_Select function or the advanced network I/O should be used. If either of these methods returns an error, there is an issue with the network socket and the evAPI instance must be cleaned up and reinitailized before trying again. (Windows only:) If the EVAPI_CreateWindow function is used, it is not necessary to call EVAPI_Select or use the advanced network I/O function to perform network I/O; the network I/O is tied to the Windows message loop and is performed automatically.
<br>
Possible reasons for a socket error:
- The connection between evAPI and the exacqVision server is closed.
- The network cable between the client computer hosting the evAPI instance and the router is disconnected.
<br>
If there is no error on the socket and the Discover request packet is sent, it is then necessary to detect ParamType Discover in the EVAPI_Callback function. If the discover response packet is received by evAPI, ParamType Discover is passed to the callback function indicating that the server was found. If no discover response is received, ParamType Discover is never passed to the callback.
The console sample shipped with the SDK contains an example of using the EVAPI_Discover function using the command line argument “discover-server”.
<br>
Example
Function evCallback(Parameters: ParamType param, int value, Payload* payload, size_t length )
Switch to handle ParamTypes
Case Discover
Disable or reset watchdog timer
End Case
End Switch
End Function evCallback
Function Main
Intialize evAPI (EVAPI_Init)
Connect to server (EVAPI_Connect)
Login to server (EVAPI_Login)
Set evAPI callback to evCallback (EVAPI_SetCallback)
Queue discover request (EVAPI_Discover)
Perform network I/O (EVAPI_Select)
If queue discover request succeeds and network I/O succeeds
Enable watchdog timer for discover paramtype in callback
Else if queue discover request fails or network I/O fails
Handle failed connection to server
End if
If the discover watchdog timer expires
Handle failed connection to server
End if End Function Main
<br>
How-to-Using-EVAPI_Discover-to-Detect-the-Connectiodn-to-an-exacqVision-Server.pdf