diff options
author | Tim Waugh <twaugh@redhat.com> | 2015-03-11 13:12:07 +0000 |
---|---|---|
committer | Tim Waugh <twaugh@redhat.com> | 2015-03-13 16:19:50 +0000 |
commit | 892d10a705077083489f0ed4861af123433ff811 (patch) | |
tree | 45a19cc088a7603eb51f1d9917efd087e0458eda /vncviewer | |
parent | a85363daa80697bda35c789b9ffca53dc7c3c71b (diff) | |
download | tigervnc-892d10a705077083489f0ed4861af123433ff811.tar.gz tigervnc-892d10a705077083489f0ed4861af123433ff811.zip |
Fixed IPv6 support.
The TcpListener constructor now takes a 'struct sockaddr*' instead of
a string, and the createTcpListeners function creates TcpListener
instances for an address based on the results from getaddrinfo().
The XserverDesktop class now takes a list of TcpListener instances for
each of the RFB and HTTP sockets.
The TcpListener::closeFd member variable is not used and has been
removed.
Diffstat (limited to 'vncviewer')
-rw-r--r-- | vncviewer/vncviewer.cxx | 34 |
1 files changed, 32 insertions, 2 deletions
diff --git a/vncviewer/vncviewer.cxx b/vncviewer/vncviewer.cxx index 3f51dd3c..876e9142 100644 --- a/vncviewer/vncviewer.cxx +++ b/vncviewer/vncviewer.cxx @@ -534,15 +534,45 @@ int main(int argc, char** argv) #endif if (listenMode) { + std::list<TcpListener> listeners; try { int port = 5500; if (isdigit(vncServerName[0])) port = atoi(vncServerName); - TcpListener listener(NULL, port); + createTcpListeners(&listeners, 0, port); vlog.info(_("Listening on port %d\n"), port); - sock = listener.accept(); + + /* Wait for a connection */ + while (sock == NULL) { + fd_set rfds; + FD_ZERO(&rfds); + for (std::list<TcpListener>::iterator i = listeners.begin(); + i != listeners.end(); + i++) + FD_SET((*i).getFd(), &rfds); + + int n = select(FD_SETSIZE, &rfds, 0, 0, 0); + if (n < 0) { + if (errno == EINTR) { + vlog.debug("Interrupted select() system call"); + continue; + } else { + throw rdr::SystemException("select", errno); + } + } + + for (std::list<TcpListener>::iterator i = listeners.begin (); + i != listeners.end(); + i++) + if (FD_ISSET((*i).getFd(), &rfds)) { + sock = (*i).accept(); + if (sock) + /* Got a connection */ + break; + } + } } catch (rdr::Exception& e) { vlog.error("%s", e.str()); fl_alert("%s", e.str()); |