use epoll single-threaded monitored data reception efficiency problem,
Int epoll_fd;
Int socktfd=socket (... )
Listen (sockfd,... )
Bind (sockfd,... )
Epoll_fd=epoll_create (MAX_EVENTS);//handle to create an epoll
//
//the add server socket fd into epoll system
//
Epoll_ctl (epoll_fd, EPOLL_CTL_ADD, server_sockfd,.. )
for( ; ;) {
//
//wait fd set data in or out
//
NFDS=epoll_wait (epoll_fd, events, MAX_EVENTS, 1);
For (int I=0; iIf (events [I]. Data. Fd==server_sockfd) {
///accpet one client
//and add to epoll system
AccpetAndAdEpollSys ();
}
The else {
///recv data from client
The recv (... );
//
//handler client message data
//
MessageHandler (... );
}
}
}
Want to ask if the concurrency value is very big, recv received come over? Whether can use multithreading to receive? Or how to deal with?
CodePudding user response:
Or not so absolutely do multithreading, can restrain conditions, such as how many client a thread management, group management client,