linux消息队列

linux消息队列发送数据是定义如下:
struct msgtype{
long type;
char mtext[200];
};
但是在使用时曾经遇到过如下问题:
msgsnd发送的数据在msgrcv接收时丢失4字节,最终排查发现我们定义的结构体中存在大于long类型的数据。以下是我们定义的结构体:
struct msgtype{
long type;
uint64_t data2;
};
这样导致type变成了八字节数据,但是我们发送的数据长度是8字节,导致尾部4字节丢失。

猜你喜欢

转载自blog.csdn.net/pengrui18/article/details/72972783