Changeset 118 in Main for trunk/Server/server.c
- Timestamp:
- Sep 21, 2024, 6:03:27 PM (8 weeks ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Server/server.c
r117 r118 39 39 #include "strptime.h" 40 40 #else 41 #ifdef USE_POLL 42 #include <poll.h> 43 #else 41 44 #include <sys/select.h> 45 #endif 42 46 #include <sys/socket.h> 43 47 #include <arpa/inet.h> … … 54 58 extern char tw_server[]; 55 59 56 fd_set fdset;57 60 int sockcount = 0; 58 61 … … 802 805 803 806 void tw_server_loop(void) { 804 struct timeval tv;805 807 int i; 806 808 #if defined(__MINGW32__) || defined(__HAIKU__) … … 810 812 } 811 813 #endif 814 #ifdef USE_POLL 815 struct pollfd pollfds[sockcount]; 816 for(i = 0; i < sockcount; i++) { 817 pollfds[i].fd = sockets[i]; 818 pollfds[i].events = POLLIN | POLLPRI; 819 } 820 #else 821 fd_set fdset; 822 struct timeval tv; 823 #endif 812 824 while(1) { 813 FD_ZERO(&fdset); 814 for(i = 0; i < sockcount; i++) { 815 FD_SET(sockets[i], &fdset); 816 } 817 tv.tv_sec = 1; 818 tv.tv_usec = 0; 825 #ifdef USE_POLL 826 int ret = poll(pollfds, sockcount, 1000); 827 #else 828 FD_ZERO(&fdset); 829 for(i = 0; i < sockcount; i++) { 830 FD_SET(sockets[i], &fdset); 831 } 832 tv.tv_sec = 1; 833 tv.tv_usec = 0; 819 834 #ifdef __HAIKU__ 820 int ret = select(32, &fdset, NULL, NULL, &tv);835 int ret = select(32, &fdset, NULL, NULL, &tv); 821 836 #else 822 837 int ret = select(FD_SETSIZE, &fdset, NULL, NULL, &tv); 838 #endif 823 839 #endif 824 840 if(ret == -1) { … … 837 853 int i; 838 854 for(i = 0; i < sockcount; i++) { 839 if(FD_ISSET(sockets[i], &fdset)) { 855 bool cond; 856 #ifdef USE_POLL 857 cond = pollfds[i].revents & POLLIN; 858 #else 859 cond = FD_ISSET(sockets[i], &fdset); 860 #endif 861 if(cond) { 840 862 SOCKADDR claddr; 841 863 int clen = sizeof(claddr);
Note:
See TracChangeset
for help on using the changeset viewer.