diff options
author | Matthias P. Braendli <matthias.braendli@mpb.li> | 2016-10-10 11:19:15 +0200 |
---|---|---|
committer | Matthias P. Braendli <matthias.braendli@mpb.li> | 2016-10-10 11:19:15 +0200 |
commit | f16f9c0634693ce0a53bb269aa2d36402e51f92f (patch) | |
tree | 028aa3f0c4010194b217b95b3573ff7f2425ac14 /src | |
parent | f8f6f43702cfb18aa7113f024f96fa2bd2b249ae (diff) | |
download | dabmux-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.cpp | 15 |
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; |