Building Networked Applications with the LabWindows/CVI TCP Support Library
- Updated2023-02-21
- 3 minute(s) read
Building Networked Applications with the LabWindows/CVI TCP Support Library
The Transmission Control Protocol/Internet Protocol (TCP/IP) suite is a set of protocols that govern how data is transferred between networked computers. TCP/IP is the primary protocol of the Internet, the Web, and many private networks and local area networks. Networking components rely on TCP transport for many activities, including the following operations:
- Internet access using HTTP
- Access to remote file servers and printers
- Distributed Component Object Model (DCOM) services
Network communication using the TCP Support Library involves a client and a server in each connection. A TCP server can send and receive information to and from a client application through a network. A TCP client can send and request data to and from a server application. Once registered, a server waits for clients to request connection to it. A client can request connection only to an existing server.
The following image displays the interaction between a TCP server and TCP client application.

With the LabWindows/CVI TCP Support Library, you can write programs to act as a TCP client or server. Two sample programs, samples\tcp\server.cws and samples\tcp\client.cws, provide guidelines for structuring TCP programs as a server or a client. These programs are provided as templates only. You must modify these programs to operate them on your computer.
To connect to a TCP server from a LabWindows/CVI program, you must have some information about the application to which you would like to connect. All TCP server applications must run on a specified host, which has a known host name, such as aaa.bbb.ccc, or a known IP address, such as 123.456.78.90, associated with it. In addition, each server has a unique port number on the host computer. These two pieces of information identify different servers on the same computer or on different computers. Before any client program can connect to a server, the client must know the host name and server port number.
If you want a program to act as a TCP server, you must call RegisterTCPServer or RegisterTCPServerEx in the program. These functions establish the program as the server associated with a port number on the local host. Call RegisterTCPServerEx to specify the address of the local host. Client applications can connect to the program by using the port number associated with the server and either the host name or the IP address of the computer on which the server application is currently running. The TCP Support Library calls the server callback function whenever the conversation partner requests communication.
Programs you write using the LabWindows/CVI TCP functions depend on the LabWindows/CVI TCP Support Library, which is part of the LabWindows/CVI Runtime. The LabWindows/CVI TCP Support Library uses the Windows Sockets (Winsock) API. Winsock provides direct access to services in the transport layer using the TCP/IP protocol. TCP establishes a connection for data transmission, and IP defines the method for sending data packets.
![]() |
Note You can call the LabWindows/CVI TCP Support Library GetHostTCPSocketHandle function to get the socket handle of a connection and then use the socket handle to call low-level socket functions. You should be familiar with system socket programming if you call low-level socket functions. System socket programming is beyond the scope of this document and is not described here. Refer www.msdn.com for more information about TCP and system socket programming. |
The following image displays components and dependencies in a LabWindows/CVI TCP application.
