04-29-2009 05:20 AM
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
04-29-2009 06:52 AM
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,
04-29-2009 10:23 AM
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.
04-29-2009 11:05 AM
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
04-29-2009 03:42 PM
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.
04-30-2009 05:39 AM
OK
I try all this.
And will soon let you know the resuts.
Thanks to JR .