📄 request.c
字号:
/****./request.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 , pid ; msqid = msgget(MSGKEY, 0666|IPC_CREAT); pid = getpid(); buf.mtext = pid ; buf.mtype = 1 ; /*向服务方发送请求,消息类型是1*/ msgsnd(msqid, &buf, sizeof(buf.mtext), 0); /*从服务方接受应答消息*/ msgrcv(msqid, &buf, 256, pid, MSG_NOERROR); printf("process %d receive a acknowledgment from server, type is :%d\n",pid, buf.mtype);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -