Hi
First giving a an overview of the whole thing i'm going to do :
there is a PC that is running a C# program(a simple TCP listener) which is the server and
6 arduino clients(using w5100 ethernet shield ) . server is sending time and date to the clients(almost
every Second), clients displaying it in a 16x2 character LCD and sending 4 voltage values from
analog pins and if a keypad number received interrupt the display and show the numbers,then send
that whole number too. (if my explanation is not clear please let me know)

In short i should send following data structure :
typedef struct
{
char ID='1' ; // this variable specifies the device sending data
char Personnel_Num[16]; // getting from Keypad
volatile int sensorValueA0; // reading volatages using analog pins
volatile int sensorValueA1;
volatile int sensorValueA2;
volatile int sensorValueA3;
}xferStruct_type;
xferStruct_type Struct_payload;
since microcontroller CPUs do memory alignments, reading and separating variables of this structure in PC could be hard .
a flashback of C language, i know that by using unions we can extract a variable size of different bytes to the bytes making it (separating each byte)
typedef union
{
volatile int sensorValueA0;
unsigned char byteVal[sizeof(int)];
}xferUnion_type;
xferUnion_type Union_payload;
and then send each byte to the PC :
int sensorValue = analogRead(A0);
Union_payload.sensorValueA0 = sensorValue; // assigning our union member to analogRead
for(int i=0 ; i < (sizeof(int)) ; ++i)
{
client.write(Union_payload.byteVal[i]);
};
although reading data is easier in this method but writing union for all of my variable will make some verbose and unprofessional code !
the question is what is the best way to send multiple data to my C# program in PC ? ( a non-blocking way to do this )
by the way if user presses a key in keypad, reading that Personnel Number can interrupt reading the
voltages should i use some kind of multi-tasking techniques?
I appreciate any help and idea.