multi-threaded concurrent foundational model and its implementation for C/S communication
发布时间
阅读量:
阅读量
本例达成以下功能:
服务端接收由客户端传输而来的字符串信息,将其小写字母转换为大写形式后再反馈给客户端。
在每一个新的客户端建立连接之后,服务端主进程会为该客户端生成一个独立的子进程,用于执行数据处理任务。
多进程并发服务端代码 :
/*server.c*/
#include <stdio.h>
#include <string.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <signal.h>
#include <sys/wait.h>
#include <sys/types.h>
#include <stdlib.h>
#include <errno.h>
#include <sys/socket.h>
#define BUFSIZE 666
#define SERV_PORT 8888
int main()
{
struct sockaddr_in servaddr, cliaddr;
socklen_t cliaddr_len;
int listenfd, connfd;
char buf[B
全部评论 (0)
还没有任何评论哟~
