ConnectTo Method

NI DataSocket

ConnectTo Method

Syntax

CWDataSocket.ConnectTo URL, AccessMode

Purpose

Connects the CWDataSocket to a data source or target.

Remarks

The ConnectTo method sets the URL and AccessMode properties to the values of the URL and AccessMode parameters passed to the method.

When connecting to a data source in a read access mode, CWDataSocket updates the data after the connection is completed. When connecting to a data target in a write access mode, DataSocket writes the data as soon as the connection is made. If you connect in an automatic update mode, CWDataSocket automatically retrieves or writes data when new data is available.

If you connect with the cwdsRead or cwdsWrite access mode, use the DataUpdated property to determine if data has been updated since the last time you checked the data.

If you connect a reading client to a DataSocket item that does not exist, the DataSocket Server creates the item with a default value of 0.

The OnDataUpdated event is generated when data is ready to be sent (in a write access mode) or has just been received (in a read access mode). You might use the OnDataUpdated event to scale, display, or process new data.

Parameters

URL As String

Location expressed as a URL of the data source or target to which the CWDataSocket is connecting.

AccessMode As CWDSAccessModes

Type of read or write connection the DataSocket makes when connecting to the data source or target (cwdsRead, cwdsReadAutoUpdate, cwdsWrite, cwdsWriteAutoUpdate).

Example

'Set the AccessMode and URL properties and connect
'to a data source.
CWDataSocket1.AccessMode = cwdsRead
CWDataSocket1.URL = "http://myhost/pata_path"
CWDataSocket1.Connect

'The AccessMode and URL also can be set with ConnectTo.
CWDataSocket1.ConnectTo "http://myhost/pata_path", cwdsRead

See Also

URL

AccessMode

Connect