HOW TO SEND nested structure through tcp ip
-
Hi sir , this my structure representation
struct request_packet { uint8_t xx; uint8_t yy; struct payload { struct A { uint8_t a1; }aa; struct B { //float c[3][3]; uint32_t b1[6][3][3]; uint32_t b2; uint32_t b3; uint32_t b4[6]; }bb; struct C { uint8_t c1; uint32_t c2; uint32_t c3; }cc; }m; };i want to send only request_packet with payload B but if send data through socket whole structure data are transmitting.
this is my code init and send data through tcp socket
struct request_packet_dkk s3,s1; uint8_t xx; uint8_t yy; s3.m.B.b1[0][0][0]=1; s3.m.B.b1[0][0][1]=2; s3.m.B.b1[0][0][2]=3; s3.m.B.b1[0][1][0]=4; s3.m.B.b1[0][1][1]=5; s3.m.B.b1[0][1][2]=6; s3.m.B.b1[0][2][0]=7; s3.m.B.b1[0][2][1]=8; s3.m.B.b1[0][2][2]=9; s3.m.B.b1[1][3][2]=11; s3.m.B.b1[1][3][3]=12; s3.m.B.b1[1][3][4]=13; s3.m.B.b1[1][4][5]=14; s3.m.B.b1[1][4][6]=15; s3.m.B.b1[1][4][0]=16; s3.m.B.b1[1][5][1]=17; s3.m.B.b1[1][5][2]=18; s3.m.B.b1[1][5][3]=19; s3.m.B.b1[2][6][4]=21; s3.m.B.b1[2][6][5]=22; s3.m.B.b1[2][6][6]=23; s3.m.B.b1[2][0][0]=24; s3.m.B.b1[2][0][1]=25; s3.m.B.b1[2][0][2]=26; s3.m.B.b1[2][1][3]=27; s3.m.B.b1[2][1][4]=28; s3.m.B.b1[2][1][5]=29; s3.m.B.b1[3][2][6]=31; s3.m.B.b1[3][2][0]=32; s3.m.B.b1[3][2][1]=33; s3.m.B.b1[3][3][2]=34; s3.m.B.b1[3][3][3]=35; s3.m.B.b1[3][3][4]=36; s3.m.B.b1[3][4][5]=37; s3.m.B.b1[3][4][6]=38; s3.m.B.b1[3][4][0]=39; s3.m.B.b1[4][5][1]=41; s3.m.B.b1[4][5][2]=42; s3.m.B.b1[4][5][3]=43; s3.m.B.b1[4][6][4]=44; s3.m.B.b1[4][6][5]=45; s3.m.B.b1[4][6][6]=46; s3.m.B.b1[4][0][0]=47; s3.m.B.b1[4][0][1]=48; s3.m.B.b1[4][0][2]=49; s3.m.B.b1[5][1][3]=51; s3.m.B.b1[5][1][4]=52; s3.m.B.b1[5][1][5]=53; s3.m.B.b1[5][2][6]=54; s3.m.B.b1[5][2][0]=55; s3.m.B.b1[5][2][1]=56; s3.m.B.b1[5][3][2]=57; s3.m.B.b1[5][3][3]=58; s3.m.B.b1[5][3][4]=59; //s3.m.B.b1[6][4][5]=122; //s3.m.B.b1[6][4][6]=123; //s3.m.B.b1[6][4][0]=123; //s3.m.B.b1[6][5][1]=111; //s3.m.B.b1[6][5][2]=193; //s3.m.B.b1[6][5][3]=168; //s3.m.B.b1[6][6][4]=186; //s3.m.B.b1[6][6][5]=124; //s3.m.B.b1[6][6][6]=187; s3.m.B.b2=1; s3.m.B.b3=1; s3.m.B.b4[0]=0xAA; s3.m.B.b4[1]=0xAA; s3.m.B.b4[2]=0xAA; s3.m.B.b4[3]=0xAA; s3.m.B.b4[4]=0xAA; s3.m.B.b4[5]=0xAA; client->write_data(QByteArray( reinterpret_cast<char*>(&s3),sizeof(s3))); -
Hi,
It's your job to extract the data you want and only send that part.