aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSalvador Fandino <sfandino@yahoo.com>2015-06-01 17:52:33 +0200
committerMike Gabriel <mike.gabriel@das-netzwerkteam.de>2016-07-04 22:57:00 +0200
commitc5a2cf82f6baf7a9e64ec2328a5bac0dfee453ef (patch)
treeb7e8ecbca3dc60f6b37afbe5226b843de5d706a2
parente0edae04db6dc189512b3a1eda7fe4516af56512 (diff)
downloadnx-libs-c5a2cf82f6baf7a9e64ec2328a5bac0dfee453ef.tar.gz
nx-libs-c5a2cf82f6baf7a9e64ec2328a5bac0dfee453ef.tar.bz2
nx-libs-c5a2cf82f6baf7a9e64ec2328a5bac0dfee453ef.zip
Rework SetupTcpSocket to use ListenConnectionTCP
-rw-r--r--nxcomp/Loop.cpp67
1 files changed, 1 insertions, 66 deletions
diff --git a/nxcomp/Loop.cpp b/nxcomp/Loop.cpp
index 5086db012..b1653bff8 100644
--- a/nxcomp/Loop.cpp
+++ b/nxcomp/Loop.cpp
@@ -3945,72 +3945,7 @@ int SetupTcpSocket()
// Open TCP socket emulating local display.
//
- tcpFD = socket(AF_INET, SOCK_STREAM, PF_UNSPEC);
-
- if (tcpFD == -1)
- {
- #ifdef PANIC
- *logofs << "Loop: PANIC! Call to socket failed for TCP socket"
- << ". Error is " << EGET() << " '" << ESTR() << "'.\n"
- << logofs_flush;
- #endif
-
- cerr << "Error" << ": Call to socket failed for TCP socket"
- << ". Error is " << EGET() << " '" << ESTR() << "'.\n";
-
- HandleCleanup();
- }
- else if (SetReuseAddress(tcpFD) < 0)
- {
- HandleCleanup();
- }
-
- unsigned int proxyPortTCP = X_TCP_PORT + proxyPort;
-
- sockaddr_in tcpAddr;
-
- tcpAddr.sin_family = AF_INET;
- tcpAddr.sin_port = htons(proxyPortTCP);
- if ( loopbackBind )
- {
- tcpAddr.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
- }
- else
- {
- tcpAddr.sin_addr.s_addr = htonl(INADDR_ANY);
- }
-
- if (bind(tcpFD, (sockaddr *) &tcpAddr, sizeof(tcpAddr)) == -1)
- {
- #ifdef PANIC
- *logofs << "Loop: PANIC! Call to bind failed for TCP port "
- << proxyPortTCP << ". Error is " << EGET() << " '" << ESTR()
- << "'.\n" << logofs_flush;
- #endif
-
- cerr << "Error" << ": Call to bind failed for TCP port "
- << proxyPortTCP << ". Error is " << EGET() << " '" << ESTR()
- << "'.\n";
-
- HandleCleanup();
- }
-
- if (listen(tcpFD, 8) == -1)
- {
- #ifdef PANIC
- *logofs << "Loop: PANIC! Call to listen failed for TCP port "
- << proxyPortTCP << ". Error is " << EGET() << " '" << ESTR()
- << "'.\n" << logofs_flush;
- #endif
-
- cerr << "Error" << ": Call to listen failed for TCP port "
- << proxyPortTCP << ". Error is " << EGET() << " '" << ESTR()
- << "'.\n";
-
- HandleCleanup();
- }
-
- return 1;
+ return ListenConnectionTCP((loopbackBind ? "localhost" : "*"), X_TCP_PORT + proxyPort, "X11");
}
int SetupUnixSocket()