当前位置: 技术问答>linux和unix
linux下并发编程,为什么显示不出来
来源: 互联网 发布时间:2016-10-11
本文导语: #include "unp.h" int main(void) { int listen_fd,accept_fd; struct sockaddr_in client_addr; socklen_t socklen=sizeof(client_addr); int n=1; pid_t pid; init_socket(listen_fd,SOCK_STREAM,client_addr,8888); setsockopt(listen_fd,SOL_SOCKET,SO_REUSEADDR,&n,sizeof(int)); listen(listen...
#include "unp.h"
int main(void)
{
int listen_fd,accept_fd;
struct sockaddr_in client_addr;
socklen_t socklen=sizeof(client_addr);
int n=1;
pid_t pid;
init_socket(listen_fd,SOCK_STREAM,client_addr,8888);
setsockopt(listen_fd,SOL_SOCKET,SO_REUSEADDR,&n,sizeof(int));
listen(listen_fd,5);
while(1)
{
accept_fd=accept(listen_fd,(struct sockaddr *)&client_addr,&client_addr);
if(errno==EINTR)
continue;
else if(accept_fd