aboutsummaryrefslogtreecommitdiff
path: root/nxcomp/Loop.cpp
diff options
context:
space:
mode:
authorSalvador Fandino <sfandino@yahoo.com>2015-06-02 13:25:34 +0200
committerMike Gabriel <mike.gabriel@das-netzwerkteam.de>2016-07-04 22:57:00 +0200
commitc92a102ba786e4b642bc454381b69d7d104ec5b5 (patch)
treef5ad439a0fbeb2ca7d80ba47333b6e5d5d5c644e /nxcomp/Loop.cpp
parent28736a8886b8c611ccf6098766b47f49ef9757b9 (diff)
downloadnx-libs-c92a102ba786e4b642bc454381b69d7d104ec5b5.tar.gz
nx-libs-c92a102ba786e4b642bc454381b69d7d104ec5b5.tar.bz2
nx-libs-c92a102ba786e4b642bc454381b69d7d104ec5b5.zip
rewrite WaitForRemote to build on top of ListenConnectionTCP
Diffstat (limited to 'nxcomp/Loop.cpp')
-rw-r--r--nxcomp/Loop.cpp63
1 files changed, 2 insertions, 61 deletions
diff --git a/nxcomp/Loop.cpp b/nxcomp/Loop.cpp
index 6dc544fe5..20114afbf 100644
--- a/nxcomp/Loop.cpp
+++ b/nxcomp/Loop.cpp
@@ -6611,7 +6611,6 @@ int WaitForRemote(int portNum)
char hostLabel[DEFAULT_STRING_LENGTH] = { 0 };
int retryAccept = -1;
- int listenIPAddr = -1;
int proxyFD = -1;
int newFD = -1;
@@ -6640,66 +6639,8 @@ int WaitForRemote(int portNum)
}
}
- proxyFD = socket(AF_INET, SOCK_STREAM, PF_UNSPEC);
-
- if (proxyFD == -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";
-
- goto WaitForRemoteError;
- }
- else if (SetReuseAddress(proxyFD) < 0)
- {
- goto WaitForRemoteError;
- }
-
- listenIPAddr = 0;
-
- ParseListenOption(listenIPAddr);
-
- sockaddr_in tcpAddr;
-
- tcpAddr.sin_family = AF_INET;
- tcpAddr.sin_port = htons(portNum);
-
- tcpAddr.sin_addr.s_addr = listenIPAddr;
-
- if (bind(proxyFD, (sockaddr *) &tcpAddr, sizeof(tcpAddr)) == -1)
- {
- #ifdef PANIC
- *logofs << "Loop: PANIC! Call to bind failed for TCP port "
- << portNum << ". Error is " << EGET() << " '" << ESTR()
- << "'.\n" << logofs_flush;
- #endif
-
- cerr << "Error" << ": Call to bind failed for TCP port "
- << portNum << ". Error is " << EGET() << " '" << ESTR()
- << "'.\n";
-
- goto WaitForRemoteError;
- }
-
- if (listen(proxyFD, 4) == -1)
- {
- #ifdef PANIC
- *logofs << "Loop: PANIC! Call to listen failed for TCP port "
- << portNum << ". Error is " << EGET() << " '" << ESTR()
- << "'.\n" << logofs_flush;
- #endif
-
- cerr << "Error" << ": Call to listen failed for TCP port "
- << portNum << ". Error is " << EGET() << " '" << ESTR()
- << "'.\n";
-
- goto WaitForRemoteError;
- }
+ proxyFD = ListenConnectionTCP( ((loopbackBind || (control->ProxyMode == proxy_server)) ? "localhost" : "*"),
+ portNum, "NX");
if (*acceptHost != '\0')
{