How to send integer with message queue with POSIX API in linux?

99封情书 提交于 2019-12-06 08:03:48
sdg

Do not read the char* in this case as the only allowed datatype.

Many *ix API use char as a generic buffer pointer.

View the interface therefore as taking a pointer to buffer and the size of the buffer.

That buffer can be anything you like, from a single int, to a struct, seralized string representation of your class, or just about anything else in memory.

int i;
mq_send(mq, (char *) &i, sizeof(i), 0);

Should work (not tested)

Good Luck

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!