static void listen_thread_fun(void* arg) { struct st_server_s* st = (struct st_server_s*)arg; sock client_fd = SOCKET_ERROR; struct sockaddr_in socketaddress; socklen_t size = sizeof(struct sockaddr); sock listen_fd = ox_socket_listen(4002, 25); if(SOCKET_ERROR != listen_fd) { for(;1;) { while((client_fd = accept(listen_fd, (struct sockaddr*)&socketaddress, &size)) < 0) { if(EINTR == sErrno) { continue; } } if(SOCKET_ERROR != client_fd) { ox_socket_nodelay(client_fd); ox_stserver_addfd(st, client_fd); } } listen_fd = SOCKET_ERROR; } else { printf("listen failed\n"); } }
static void listen_thread(void* arg) { sock client_fd = SOCKET_ERROR; struct sockaddr_in socketaddress; socklen_t size = sizeof(struct sockaddr); struct nr_mgr* mgr = (struct nr_mgr*)arg; sock listen_fd = ox_socket_listen(SERVER_PORT, 25); if(SOCKET_ERROR != listen_fd) { for(;;) { while((client_fd = accept(listen_fd, (struct sockaddr*)&socketaddress, &size)) < 0) { if(EINTR == sErrno) { continue; } } if(SOCKET_ERROR != client_fd) { //printf("accept client_fd : %d \n", client_fd); ox_nrmgr_addfd(mgr, NULL, client_fd); } } ox_socket_close(listen_fd); listen_fd= SOCKET_ERROR; } else { printf("listen failed\n"); } }