void onAcceptEvent( aeEventLoop *el , int fd , void *privdata , int mask ) { if (servG->listenfd == fd) { int client_port,connfd,max = 1000; char client_ip[46]; char neterr[1024]; while (max--) { connfd = anetTcpAccept( neterr , fd , client_ip , sizeof( client_ip ) , &client_port ); if (connfd == -1) { if (errno != EWOULDBLOCK) { printf( "Accepting client Error connection: %s \n" , neterr ); } return; } acceptCommonHandler( servG , connfd , client_ip , client_port ); } } else { printf( "onAcceptEvent other fd=%d \n" , fd ); } }
void acceptTcpHandler(aeEventLoop *el, int fd, void *privdata, int mask) { int cport, cfd, max = MAX_ACCEPTS_PER_CALL; char cip[NET_IP_STR_LEN]; UNUSED(el); UNUSED(mask); UNUSED(privdata); while(max--) { cfd = anetTcpAccept(server.neterr, fd, cip, sizeof(cip), &cport); if (cfd == ANET_ERR) { if (errno != EWOULDBLOCK) Log(WARNING, "Accepting client connection: %s", server.neterr); return; } Log(VERBOSE,"Accepted %s:%d", cip, cport); acceptCommonHandler(cfd,0); } }