# TCP Clients and Servers

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.

With the LabWindows/CVI TCP Support Library, you can write programs to act as a TCP client or server. Two sample programs, server.prj and client.prj, 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 function 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.