LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

We want to send a struct to a client by the ServerTCPWrite function. How can we do this ?

typedef struct
{
int a;
int b;
int c;
int d;
int e;
} Telegramm;

Telegramm temp;
...
ServerTCPWrite(panel, &temp, dataSize, 1000);
...
----------
...
ClientTCPRead(panel, &temp, dataSize, 1000);
...


This does not work...
We are just beginners in programming LabWindows/CVI and have not found this problem in the online manual.

We would be thankful for any help !!!
0 Kudos
Message 1 of 2
(2,666 Views)
TCP requires you flatten everything to string. It transmits in ASCII. So you would have to write functions to convert your structure into a string on the Server side, and a function to parse the string back into the structure on the client side.

In this case something for the server like:

char buffer[100];

Fmt(buffer, "%5d", temp.a, temp.b, temp.c, temp.d, temp.e);
ServerTCPWrite(panel, buffer, dataSize, 1000);

and for the client like:

char buffer[100];

ClientTCPRead(panel, buffer, dataSize, 1000);
Scan(buffer, "%5d", temp.a, temp.b, temp.c, temp.d, temp.e);

Hope that helps.

Best Regards,

Chris Matthews
National Instruments
0 Kudos
Message 2 of 2
(2,666 Views)