TCP/IP协议
协议模型
No Image
Socket编程
根据系统实现了TCP/UDP或者IP层的接口,调用该 接口进行网络编程
网络编程
网络编程
服务器编程:创建套接扣绑定套接口设 置套接口为监听模式,进入被动接受连接请 求状态接受请求,建立连接读/写数据 终止连接
客户端程序:创建套接口与远程服务程序 连接读/写数据终止连接
值为0,父进程中执行,返回值为子进程ID。 调用方法: #include <sys/type.h> #include <unistd.h> Pid_t fork(void); Pid_t vfork(void);
#include<sys/types.h> #include<unistd.h> #include<stdio.h> Int main(void) { pid_t pid; if ((pid=fork())<0) err_sys(“fork error\n”); Else if(pid==0) printf(“this is process of child!\n”); Else printf(“parent process pid=%d! \n”,getpid());
发送消息
int msgsnd(int msqid,const void *msgp,size_t msgsz,int msgflg);
接收消息
int msgrcv(int msqid,void *msqp,size_t msgsz,long msgtyp,int msgflg);
销毁消息队列
Wait和waitpid函数 作用:等待子进程终止函数 区别:waitpid与wait的作用相同,waitpid