86 |
// now wait for client connections and handle their requests |
// now wait for client connections and handle their requests |
87 |
sockaddr_in client; |
sockaddr_in client; |
88 |
int length = sizeof(client); |
int length = sizeof(client); |
|
struct timeval tv; |
|
|
tv.tv_sec = 30; |
|
|
tv.tv_usec = 0; |
|
89 |
FD_ZERO(&fdSet); |
FD_ZERO(&fdSet); |
90 |
FD_SET(hSocket, &fdSet); |
FD_SET(hSocket, &fdSet); |
91 |
int maxSessions = hSocket; |
int maxSessions = hSocket; |
96 |
|
|
97 |
while (true) { |
while (true) { |
98 |
fd_set selectSet = fdSet; |
fd_set selectSet = fdSet; |
99 |
int retval = select(maxSessions+1, &selectSet, NULL, NULL, &tv); |
int retval = select(maxSessions+1, &selectSet, NULL, NULL, NULL); |
100 |
if (retval == 0) |
if (retval == 0) |
101 |
continue; //Nothing in 30 seconds, try again |
continue; //Nothing try again |
102 |
if (retval == -1) { |
if (retval == -1) { |
103 |
std::cerr << "LSCPServer: Socket select error." << std::endl; |
std::cerr << "LSCPServer: Socket select error." << std::endl; |
104 |
close(hSocket); |
close(hSocket); |