Elaborato_SO/src/F4Client.c

39 lines
777 B
C
Raw Normal View History

2023-05-15 11:24:39 +02:00
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/ipc.h>
2023-05-16 15:55:05 +02:00
#include <sys/stat.h>
#include <sys/msg.h>
2023-05-15 11:24:39 +02:00
#include <custom_sem.h>
#include <structures.h>
#include <custom_shm.h>
//TODO: mettere main ma non l'ho fatto per makefile
int client(){
2023-05-16 15:55:05 +02:00
// MSGQ
key_t msgKey = ftok(KEYFILE, 'M');
int msqid = msgget(msgKey, IPC_CREAT | S_IRUSR | S_IWUSR);
if (msqid == -1) {
errExit("msgq", "F4Client");
}
if (msgrcv(msqid, ) == -1){
errExit("msgrcv", )
}
//
int semid;
2023-05-15 11:24:39 +02:00
semOp(semid, 0, -1); // aspetta che il server gli dia il permesso di connettersi
printf("\033[94m<Client>\033[39m Connecting to server...\n");
semOp(semid, 1, -1); // finito operazioni di connessione
return 0;
}