Guest User

Untitled

a guest
Jul 4th, 2019
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. void receive()
  2. {
  3. int ns, i0;
  4. socklen_t sosize;
  5. while(1)
  6. {
  7. if (_ctrlc) break;
  8. sosize = sizeof(clientAddress);
  9. ns = accept(sockfd,(struct sockaddr*)&clientAddress,&sosize);
  10. if (ns < 0)
  11. {
  12. if (errno == EWOULDBLOCK || errno == EAGAIN) {
  13. i0 = 0; while (i0 < sW) {
  14. if (W[i0].used == 2) disp((void *)(W + i0));
  15. i0++;
  16. }
  17. sleep(0.01);
  18. } else {
  19. _LOG1("net break\n");
  20. break;
  21. }
  22. } else {
  23. i0 = 0; while (i0 < sW) if (W[i0].used) i0++; else break;
  24. if (i0 < sW)
  25. {
  26. _LOG2("accept to #%i\n",i0);
  27. W[i0].Init(ns, thre);
  28. pthread_create(&serverThread,NULL,&Task,(void *)(W + i0));
  29. } else {
  30. _LOG1("reject\n");
  31. close(ns);
  32. }
  33. }
  34. }
  35. printf("exit\n");
  36. close(sockfd);
  37. }
Advertisement
Add Comment
Please, Sign In to add comment