the shared memory:
Code:
key_t key;
int shmid,semid;
char *data;
key = 123;
if ((shmid = shmget(key, 1024, IPC_CREAT | 0600)) == -1)
printf("error");
data = shmat(shmid, NULL, 0);
shMemPointerToTopics = data;
a function that is called:
Code:
void StaticTopics(int topNumber){
staticTopics[topNumber].topicID=321;
staticTopics[topNumber].baseTopicName="anorthosis";
staticTopics[topNumber].thema[topNumber].sender="Timour Ketspagia";
staticTopics[topNumber].thema[topNumber].message="Vradies champions league";
}
the part which initializes that. i am using the write for testing, if the variables were initialized right.
Code:
childpid = fork();
if ( childpid == 0 ) {
StaticTopics(1);
write(connfd,staticTopics[1].thema[1].sender,15);
}