For my program, when a client joins a MQ that was created by a server, the server starts a thread and in that thread will create a private MQ that only one specific client will have the key to.
When I create a key, since it will be one of many, does it have to have a special name? Or can I use the same one when calling ftok()
?
example code:
void *thread_function(void *arg){
key_t keyT;
int temp;
temp = i;
struct my_msgbuf bufT;
keyT=ftok("server.c", 'B'); //create key for client[temp]
if ((client[temp].mqID=msgget(keyT, 0666 | IPC_CREAT))==-1){ //private mq for client[temp]
perror("msgget");
}
}
Or will have I have to make a array of key_t
's, a different key for each thread?
And does keyT=ftok("server.c", 'B');
create the same key anytime you use it?