/*服务器*/
#include<stdio.h>
#include<stdlib.h>
#include<sys/types.h>
#include<sys/stat.h>
#include<unistd.h>
#include<fcntl.h>
#include<string.h>
#include<errno.h>
#define SERVER_FIFO "server_fifo"/*服务器管道*/
#define FILE_MODE (S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH)
#define MAXLINE 4096
/*从一个描述符读文本行,一次1个字节*/
ssize_t readline(int fd, void *vptr, size_t maxlen)
{
ssize_t n, rc;
char c, *ptr;
ptr = vptr;
for(n = 1; n < maxlen; n++)
{
again:
if((rc = read(fd, &c, 1)) == 1)
{
*ptr++ = c;
if(c == '\n')
break;
}
else if(rc == 0)
{
*ptr = 0;
return (n - 1);
}
else
{
if
FIFO实现并发服务器——多进程
最新推荐文章于 2022-05-15 10:36:00 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)