2
I have a struct that I would like to serialize/disallow to send in a connection via sockets using the function send and recover that struct with the function recv, what are the ways I can solve this problem? I am aware of the function htons but I haven’t figured out how to use it effectively in a struct.
Struct to Serialize/Deserialize
struct header
{
    uint32_t payload_len;
    uint32_t psecret;
    uint16_t step;
    uint16_t student_id;
};
typedef struct header Cabecalho;
struct packet
{
    Cabecalho* cabecalho;
    char* msg;
};
typedef struct packet Pacote;
In that case I need to send the struct packet to the network.