Showing results for 
Search instead for 
Did you mean: 

does anyone have an example of a c++ TCP/IP client that works with labview TCP?IP server ??

I have the labview TCP/IP client/server working fine, but now I need to do this were labview is the TCP/IP server and the c++ program is the client. Does anybody have a simple C++ TCP/IP client that works with labview TCP/IP server ????
0 Kudos
Message 1 of 4
I haven't done it with c++ but I once wrote a LabWindows/CVI client program that connected to either a LabVIEW or Visual Basic server and the CVI program didn't care which server was running. I just specified the port and host name. I would imagine that the c++ method is similar and if your development system has any TCP client examples, it should work with any TCP server.
0 Kudos
Message 2 of 4
Hi there,

Because TCP/IP is a protocol it doesn't matter if you write the client in C++ or the server in LabVIEW (or vice verse) because they speak "the same language". What you need in c++ is to create a TCP socket (a socket is the IP-adress and port together e.g. IP-address port 34 is a TCP socket and there a many examples of this available.

However you could run into problem when trying to intepret the transmitted data. For example, if you try to pass a U32 to the server, the U32 is transformed into four bytes. You have to beware of the endian use. I've runned into problems where the C++ uses a big endian and LabVIEW uses little endian (or was it vice verse? Don't remember!). In LabVIEW "flatten into string", "unflat
ten from string" and "reverse string" VIs is very useful together with the usual TCP VIs. All you really have to do is to reverse the byte order for each numeric type before transmitting to the server.
Message 3 of 4
Thanks, you were right, we modified the c++ program to include the port # in the IP address and it worked.We also forgot to convert the port #. I included my labview and c++ program.
Download All
0 Kudos
Message 4 of 4