简体   繁体   中英

sending nested struct over UDP api that accept string

I am using a UDP api that basically accept string parameter to be send only.

send_udp(str data, ip_address dest);

so the thing is that I have a struct below

typedef struct 
{   
int bmw_red; 
}vm_car_type;


 typedef struct  
{
    int             numberofbuying;
    vm_car_type bmw;
}  msg_type;

The problem is that I can basically want to send the msg_type struct (that contains another struct inside it), serialize the whole struct to string, and send it using send_udp message. I do not know how to serialize this msg_type into string, so that it can be send.

Does anyone have a suggestion what to do, as I can not use any other library to serialize this, so just xml parser. I have the receiver parser, but I can not get the idea of how to serialize the above struct to xml, so I am trying to find any ways to convert the struct to string

Thank you for any suggestions.

这是 Beej的C网络编程指南中一些序列化信息。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM