Skip to content

Instantly share code, notes, and snippets.

@gitsrc
Created August 1, 2018 14:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gitsrc/96628950cdc284e66d40bef770e15c99 to your computer and use it in GitHub Desktop.
Save gitsrc/96628950cdc284e66d40bef770e15c99 to your computer and use it in GitHub Desktop.
posix-queue-client
#include <stdio.h>
#include <mqueue.h>
#include <errno.h>
#include <string.h>
#include <stdlib.h>
#define PATH_URI "/corermanipc"
#define MAX_LEN 2000
int main(){
char *info = (char*)malloc(sizeof(char)*MAX_LEN);
strcpy(info,"Hello world");
int sendlen =0;
mqd_t mqd = mq_open(PATH_URI,O_WRONLY,0x777,NULL);
if (mqd == -1){
printf("MQ open faild : %s\n",strerror(errno));
}else{
struct mq_attr mqatt;
mq_getattr(mqd,&mqatt);
while(1){
sendlen = mq_send(mqd,info,strlen(info),0);
if(sendlen == -1){
printf("MQ recv faild : %s\n",strerror(errno));
}
}
}
free(info);
mq_close(mqd);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment