#include #include #include #include #include #include #define key_in 1234 #define key_out 4321 #define size 1024 static int send_id; static int receive_id; int main() { int n,tooutput_id,toinput_id,receive_id,send_id; char text[size]; //key_out as input as this is the msgq where client will send its output toinput_id=msgget(key_out, IPC_CREAT); if (toinput_id == -1) { printf("input msgget failed ...\n"); return -1; } tooutput_id=msgget(key_in, IPC_CREAT); if (tooutput_id == -1) { printf("output msgq failed ...\n"); return -1; } printf("Server ...\n"); while(1) { receive_id = msgrcv(toinput_id,text,strlen(text),0,0); if(receive_id < 0) { printf("msgrcv failed ...%d\n", errno); return -1; } if(strcmp(text,"quit")==0) { msgsnd(tooutput_id,text,strlen(text),0); printf("<>\n"); msgctl(toinput_id,IPC_RMID,0); msgctl(tooutput_id,IPC_RMID,0); return 0; } puts(text); for (n=0;n