send a struct via UDP (Without serialization)
Unsolved
General and Desktop
-
Hi,
I have this struct :
typedef struct myStruct { int nb_trame; bool tabBool[20]; } myStruct;
How do I send it via a QUdpSocket (without QDataStream) ?
I thought this will work :
myStruct a; //set 'a' variable mySocket->writeDatagram( (const char*) &a, sizeof(a), someQHostAddress, somePort);
But some people told me it won't..
If possible, i would like to have a code answer x) Because I'm a noob in networking...
I'm using Visual C++ 2010. -
@Punt said:
QDataStream
Is there a reason you will not use QDataStream ?
It helps you with network details like byte order etc.
What you are doing is very likely to blow up hard
if u send to other pc ( that has different architecture)
and just superimpose(cast) a myStruct over the received data.Normally you would use serialization. :)