Admin Production ni-theme
Current Publication

CNSNewScalarEndpoint

LabWindows/CVI

CNSNewScalarEndpoint

int CNSNewScalarEndpoint (char *endpointUrl, char *otherEndpointUrl, CNSType dataType, size_t numItems, size_t itemSize, CNSDirection direction, int timeout, intptr_t reserved, CNSEndpoint *endpointID);

Purpose

Creates a reader or writer endpoint of a network stream that transmits scalars of the type specified by the dataType parameter. Numeric scalars and strings are supported.

Endpoints can be active or passive. An active endpoint tries to connect to another endpoint, while a passive endpoint waits for a connection. If you pass NULL or an empty string to otherEndpointUrl, you create a passive endpoint.

Parameters

Input
Name Type Description
endpointUrl char * The URL of the local endpoint.
otherEndpointUrl char * The URL of the endpoint you want to connect to. If you pass NULL or an empty string to otherEndpointURL, you create a passive endpoint, meaning that the endpoint waits for a connection.
dataType CNSType The data type of the network stream.
numItems size_t The size of the buffer in number of elements. The minimum size is one element.
itemSize size_t Determines how to allocate memory for the network stream endpoint buffers.

If you want to pre-allocate memory for your network stream data, specify the combined total of the maximum size of each data element, plus an additional 4 bytes to hold the size of the network stream data.

If you do not want pre-allocate memory, pass 0 for this parameter.
direction CNSDirection Specifies whether the endpoint you create with this function is a writer endpoint or reader endpoint. You can specify one of the following values:

Value Description
CNSDirectionReader Create a reader endpoint
CNSDirectionWriter Create a writer endpoint
timeout int The time, in milliseconds, that this endpoint waits to connect to the other endpoint or waits for the other endpoint to connect to it. The default value is CNSWaitForever, which means this endpoint waits indefinitely. If the timeout expires, this function returns an error.
reserved intptr_t This parameter is reserved for use by the Network Streams Library. You must pass 0 for this parameter.
Output
Name Type Description
endpointID CNSEndpoint The handle to the network stream endpoint created by this function.

Return Value

Name Type Description
error int An error code returned by a Network Streams Library function.

Additional Information

Library: Network Streams Library

Include file: cvinetstreams.h

LabWindows/CVI compatibility: LabWindows/CVI 2013 and later

Examples

Refer to the following examples that use the CNSNewScalarEndpoint function:

  • networkstreams\cnsGUI.cws

    Open example
  • networkstreams\cnsSimple.cws

    Open example