eth32_open

eth32 eth32_open(char *address, WORD port, unsigned int timeout, int *result);

Summary

The eth32_open function is used to open a new connection to an ETH32 device. It returns a handle which you must save and pass to any other API functions you call. Note that your application may have connections open to several ETH32 devices at once, so the handle serves to identify each connection. This function does not reset the device or change its configuration in any way.

Parameters

  • address - The IP address or DNS name of the ETH32 device.

  • port - The TCP port to connect to. The ETH32 listens on TCP port 7152. The constant ETH32_PORT may be used here.

  • timeout - Specifies the maximum time, in milliseconds, that the connection attempt may take, excluding resolving DNS. You may specify a timeout of zero to use the default timeout from the system's TCP/IP stack. Note that the function may time out in less time than you specify if the system's timeout is shorter.

  • result - Receives the result/error code of the function. You may specify NULL if you are not interested in the error code. On a successful connection, a value of zero is stored to this parameter. On error, the error code is stored. See the Error Codes section for possible error codes.

Return Value

This function returns a handle to the device if it was successfully opened. You must save the handle value and pass it as a parameter to any other API functions that you call. The only return value that indicates an error is zero. If you want to receive the actual error code in the event of an error, use the result parameter specified above.

Example
eth32 handle;
int result;

handle=eth32_open("192.168.1.100", ETH32_PORT, 0, &result);
if(handle==0)
{
	printf("Error connecting to ETH32: %s\n", eth32_error_string(result));
	// handle error as appropriate in your code, prevent falling through
	// to code below.	
}
// Now that we're connected, turn on an LED:
eth32_set_led(handle, 0, 1);
         
See Also

eth32_close, eth32_verify_connection