Connect Method

Public Sub Connect(ByVal address As String, Optional ByVal port As Long = ETH32_PORT, _
                   Optional ByVal timeout As Long = 0)

Summary

The Connect method is used to open a connection to an ETH32 device. You must call Connect and successfully connect to an ETH32 device before calling other methods or accessing other properties of the Eth32 object. This method 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. If an overloaded method without this parameter is called, the constant ETH32_PORT (7152) is used, which is the port the ETH32 listens on.

  • 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, which is the default if this parameter is not specified. Note that the method may time out in less time than you specify if the system's timeout is shorter than what you specify. If the method does time out, it will raise an EthErrorTimeout error.

Return Value

This method does not have a return value. If any error occurs, an error will be raised.

Remarks

Once an object is connected to a device, you may not call Connect again on that object unless you first disconnect using the Disconnect Method. Note that your application may have connections open to several ETH32 devices at once. Each requires a separate Eth32 object to be created in your application.

Example
Private Sub example()
    
    ' Set up error handling for this routine
    On Error GoTo myerror
    
    Set dev = New Eth32
    
    ' NOTE: Substitute the IP address or DNS name of your device here.
    dev.Connect "192.168.1.100", ETH32_PORT, 10000
    
    ' Now that we're connected, turn on an LED:
    dev.Led(0) = True

    Exit Sub
myerror:
    If Err.Number = EthErrorTimeout Then
        MsgBox "Timed out while connecting to ETH32."
    Else
        MsgBox "Error connecting to ETH32: " & dev.ErrorString(Err.Number)
    End If
End Sub
        
See Also

Connected Property, Disconnect Method