1、使用多进程,实现多个客户端同时下载文件
目录:
头文件
#include <sys/types.h>#include <sys/stat.h>#include <fcntl.h>#include <unistd.h>#include <stdio.h>#include <stdlib.h>#include <sys/uio.h>#include <sys/socket.h>#include <string.h>#include <sys/epoll.h>#include <netinet/in.h>#include <arpa/inet.h>#define FILENAME "file"typedef struct childdata{ pid_t pid; int fdw; short busy;//标示子进程是否忙碌}cdata,*pcdata;typedef struct tdata{ int len; char buf[1000];}td,*ptd;void make_child(pcdata,int);void set_init(int,char*,char*);void send_file(int);服务器端: 客服端:
进程数
新闻热点
疑难解答