Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void receive()
- {
- int ns, i0;
- socklen_t sosize;
- while(1)
- {
- if (_ctrlc) break;
- sosize = sizeof(clientAddress);
- ns = accept(sockfd,(struct sockaddr*)&clientAddress,&sosize);
- if (ns < 0)
- {
- if (errno == EWOULDBLOCK || errno == EAGAIN) {
- i0 = 0; while (i0 < sW) {
- if (W[i0].used == 2) disp((void *)(W + i0));
- i0++;
- }
- sleep(0.01);
- } else {
- _LOG1("net break\n");
- break;
- }
- } else {
- i0 = 0; while (i0 < sW) if (W[i0].used) i0++; else break;
- if (i0 < sW)
- {
- _LOG2("accept to #%i\n",i0);
- W[i0].Init(ns, thre);
- pthread_create(&serverThread,NULL,&Task,(void *)(W + i0));
- } else {
- _LOG1("reject\n");
- close(ns);
- }
- }
- }
- printf("exit\n");
- close(sockfd);
- }
Advertisement
Add Comment
Please, Sign In to add comment