For the last portion of Networking we will look at a client-server model using only labview. Just like the C-server, the labview server also makes a listen call using the TCP Listen.vi. The reads and writes are the same ones used in the labview clients that we have previously looked at.
We are going to look at the same three examples that we have used in the previous sections, using the same labview clients as before. Since we have already seen the labview clients, we will focus on the labview servers.
The first example for this section is in the Ls_Lc/Ls_Lc1/ directory. After the TCP listen.vi is used to make the connection, there is a while loop that corresponds to the while loop in the client. The first read checks to see if we want the connection to continue. This read is wired into a case structure which issues a true if a 1 is read, or a false if a 0 is read. The while loop will continue until a false is registered. The two factors are then read in, followed by the product being computed and written back to the client.
Now on to the next example, also in the Ls_Lc/Ls_Lc2/ directory. After making the connection and checking to see if we want the connection to continue as before, we read in a cluster of information. As in all of the previous reads, we have to convert each element in the cluster back to its proper data type. This is done in a similar fashion to what we have previously done. To do this we still use the Type Cast icon. Instead of wiring in one constant for the data type, we have to wire a constant for each object in the cluster. This is done by using a bundle icon to create a cluster of constants that we can then wire to the top of the Type Cast icon. We can then use the unbundle icon to access the information so that the calculations can then be made and returned to the client.
The final Networking example is also found in the Ls_Lc/Ls_Lc3/ directory. In this example, upon receiving the main cluster of information, each group of young, area and length is broken up into its own cluster and then they are all inserted into an array. The array is then passed into a for loop. The for loop automatically indexes the array and accesses each cluster, makes the proper computation, and sends the result back to the client. The first cluster that is recieved, rather than being unbundled and put into an array, is just converted from a cluster to an array using the Cluster to Array icon. It is also passed to the for loop and automatically indexed.
|