aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2016-10-10 11:19:15 +0200
committerMatthias P. Braendli <matthias.braendli@mpb.li>2016-10-10 11:19:15 +0200
commitf16f9c0634693ce0a53bb269aa2d36402e51f92f (patch)
tree028aa3f0c4010194b217b95b3573ff7f2425ac14 /src
parentf8f6f43702cfb18aa7113f024f96fa2bd2b249ae (diff)
downloaddabmux-f16f9c0634693ce0a53bb269aa2d36402e51f92f.tar.gz
dabmux-f16f9c0634693ce0a53bb269aa2d36402e51f92f.tar.bz2
dabmux-f16f9c0634693ce0a53bb269aa2d36402e51f92f.zip
Replace select() by poll() for TcpSocket accept
Diffstat (limited to 'src')
-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;