LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

DataSocket vs TCP/IP For Private Network

I have an application which uses a laptop to display data captured in real time by a remote PC on a private network. Originally, I used the CVI TCP libraries to implement the design and it all worked fine.

I was a bit unhappy at having to specify arbitrary TCP port numbers for the client and server; also I was contemplating sending the data to more than one destination, so after I saw (somewhere in the CVI help guides) that the DataSocket approach "is easier to program than TCP", didn't need hard coded port numbers and could easily accommodate multiple data display stations, I thought I would give it a go.

After rather more coding than I was expecting to have to write, I got the system running in a similar manner to the TCP version. Unfortunately, the system performance was not adequate (even using buffered data I was losing packets): from reading various other forum messages I have concluded that I would need to add even more code to implement some form of flow control/handshaking for the DataSockets in order to correct the problem.

Enough. I'm going back to my original point-to-point TCP implementation. Is there a more sensible way (in CVI 7.0 FDS) to assign TCP port numbers than simply making them up and hoping that no-one else is using them?

TIA

JR
0 Kudos
Message 1 of 5
(3,473 Views)
You should be ok with port numbers greater than 1024. Usually with such applications, you could make the port number user configurable. So incase the connection fails because someone is using the port (one way to check whether a port is in use), the user can change the value.

Another way to detect used ports on a system would be to parse the output of the "netstat" command. Try typing "netstat /? "on the console for more information about this command.

Check out this link for information about port numbers.

Hope this helps
Bilal Durrani
NI
0 Kudos
Message 2 of 5
(3,462 Views)
Thanks for the link. I already have an .ini file in which the user stores the port number - this will do for now. (Seems it would be best to use a port number above 49152, according to the link.) I will look into the possibility of using your netstat suggestion to programmatically identify ports that are already in use on the server; the port number subsequently selected for my application can then be written into the server's .ini file and FTP'ed by the client for it to read remotely, so that it can connect correctly.

Do you know of any SDK/kernel calls to perform this function?

Thanks again.

JR
0 Kudos
Message 3 of 5
(3,455 Views)
You could check out the Winsock Windows SDK Help for this. I have not tried my hand at a port sniffer, but Im pretty sure the main idea would be to launch multiple threads and try connecting to each port. Im not sure about how netstat is doing this though.
Bilal Durrani
NI
0 Kudos
Message 4 of 5
(3,451 Views)
Following your link, I found a useful tip here. I'd guess this is how netstat works.

Thanks for your help.

JR
0 Kudos
Message 5 of 5
(3,437 Views)