#include #include #include #include #include #include #include using namespace std; typedef struct { long mtype,msg; char buffer[40]; }message ; int main(void){ int id; key_t key; key = getuid(); message m; if ((id = msgget(key, IPC_CREAT | 0660)) == -1){ perror("Queue creat"); exit(1); } cout << "id is " << id << "\n"; m.mtype = 1; strcpy(m.buffer, "hello"); if(msgsnd(id, &m, sizeof(message), IPC_NOWAIT) == -1) { perror("Client: msgsnd"); exit(5); } cout << "Send complete\n"; msgctl(id, IPC_RMID, (struct msqid_ds *) 0); /* remove*/ exit(0); }