aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/TcpSocket.cpp15
1 files changed, 5 insertions, 10 deletions
diff --git a/src/TcpSocket.cpp b/src/TcpSocket.cpp
index 6e7c31d..433e5c1 100644
--- a/src/TcpSocket.cpp
+++ b/src/TcpSocket.cpp
@@ -32,6 +32,7 @@
#include <string.h>
#include <signal.h>
#include <stdint.h>
+#include <poll.h>
using namespace std;
@@ -168,17 +169,11 @@ TcpSocket TcpSocket::accept()
boost::optional<TcpSocket> TcpSocket::accept(int timeout_ms)
{
- fd_set rfds;
- struct timeval tv;
- int retval;
+ struct pollfd fds[1];
+ fds[0].fd = m_sock;
+ fds[0].events = POLLIN | POLLOUT;
- FD_ZERO(&rfds);
- FD_SET(m_sock, &rfds);
-
- tv.tv_sec = 0;
- tv.tv_usec = 1000ul * timeout_ms;
-
- retval = select(1, &rfds, NULL, NULL, &tv);
+ int retval = poll(fds, 1, timeout_ms);
if (retval == -1) {
stringstream ss;