/***************************************************** * The TCP socket server to help you to test if your * OS supports c1000k(1 million connections). * @author: ideawu * @link: http://www.ideawu.com/ *****************************************************/ #include #include #include #include #include #include #include #include #define MAX_PORTS 100 int main(int argc, char **argv){ if(argc < 2){ printf("Usage: %s port\n", argv[0]); exit(0); } struct sockaddr_in addr; const char *ip = "0.0.0.0"; int opt = 1; int bufsize; socklen_t optlen; int connections = 0; int base_port = 7000; if(argc >= 2){ base_port = atoi(argv[1]); } int server_socks[MAX_PORTS]; int i; int port; for(i=0; i maxfd){ maxfd = server_socks[i]; } } int ret = select(maxfd + 1, &readset, NULL, NULL, NULL); if(ret < 0){ if(errno == EINTR){ continue; }else{ printf("select error! %s\n", strerror(errno)); exit(0); } } if(ret == 0){ continue; } for(int i=0; i