Created
August 1, 2018 14:40
-
-
Save gitsrc/96628950cdc284e66d40bef770e15c99 to your computer and use it in GitHub Desktop.
posix-queue-client
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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