开发者

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), se开发者_运维技巧rialize 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.


Here's some serialization information from Beej's C networking programming guide.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜