📄 service.c
字号:
/*./service.c*为请求进程服务的服务方进程*/#include <errno.h>#include <sys/types.h>#include <sys/ipc.h>#include <sys/msg.h>#define MSGKEY 3756main(){ struct msgbuf{ int mtype; int mtext; }buf; int msqid, tmp; msqid = msgget(MSGKEY, IPC_CREAT|0666); for(;;){ /*接受请求*/ msgrcv(msqid, &buf, 256, 1, MSG_NOERROR); tmp = buf.mtext; printf("server receive a request from process %d\n", tmp); buf.mtype = tmp ; /*向请求进程发送应答消息*/ msgsnd(msqid, &buf, 1, 0); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -