LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

TCP/IP message structure

Hello

Can somebody help me:

I am using Labwindows CVI (Labview later). I am writing a Client Server application that exchange messages . I need  the TCP/IP streams of the messages start with 

- a 16 bytes header containaing a header Identifier, a stream format version, a Header length, and the Total stream length .

Do you know how to do this ?

Do you know what are Serialization Version Identifier and Stream format version ?

Thanks for your help.

Best regards.

codjovi

0 Kudos
Message 1 of 6
(4,178 Views)

Did you check the TCP/IP library?

It includes the functions to create a connection to a server and to send/receive data over TCP/IP.

 

The content of the messages you send over TCP/IP is not important for the library.

It just manages the communication channel.

 

You'll receive at the receiver side the exact bytes that are sent by the transmitter.

It is upto you how to format them as "header identifier", "stream format version", etc.

 

Hope I did understand your problem correctly,

S. Eren BALCI
IMESTEK
0 Kudos
Message 2 of 6
(4,170 Views)

TCP/IP library functions deal with void* dataPointer... My problem is to organize what dataPointer is pointing to  (hexa + String + Variant ... )

So to clarify my question:

1)What (and how) should I send if I want the server to receive a stream like $4A $59 $49 $50 $03 $00 $00 $00 $10 $00 $00 $00 $60 $00 $00 $00 $01 $0C $20 $00 ... that can represent different types of data.(hexa , String, Variant...)

2) Where can I find the binary stream actually sent by ClientTCPWrite and pointed to by dataPointer.

0 Kudos
Message 3 of 6
(4,150 Views)

Probably the easiest way is to define a structure to both the sender and receiver, along the lines of :

 

typedef struct {               // Sample typedef for your structure header

    unsigned char header_ID;

    unsigned char version;

    unsigned short hdr_len;

    unsigned int msg_len;

} Header_type;

 

Header_type hdr;               // Define an instance of the structure

 

hdr.header_ID = 99;            // Set the various values...

 

ServerTCPWrite (..., (void *) hdr, sizeof (hdr), ...);   // Cast to void * may not actually be necessary

 

And something similar at the receiver end.

 

JR

   

0 Kudos
Message 4 of 6
(4,142 Views)

You can pass any array as void *dataPointer.

But you have to set the number of elements correctly. You can use the sizeof operator for this purpose.

 

The values you have sent are perfect for sending as an unsigned char array.

You can parse it at the receving end to determine the header, data, .. etc. 

 

The method suggested by JR is better since it gives you a structued access to the data. 

S. Eren BALCI
IMESTEK
0 Kudos
Message 5 of 6
(4,126 Views)

OK

I try all this.

And will soon let you know the resuts.

Thanks to JR .

0 Kudos
Message 6 of 6
(4,108 Views)