linuxdcpp-team team mailing list archive
-
linuxdcpp-team team
-
Mailing list archive
-
Message #04873
[Branch ~dcplusplus-team/dcplusplus/trunk] Rev 2703: ignore getaddrinfo errors when setting up listening sockets
------------------------------------------------------------
revno: 2703
committer: poy <poy@xxxxxxxxxx>
branch nick: trunk
timestamp: Tue 2011-12-06 20:51:07 +0100
message:
ignore getaddrinfo errors when setting up listening sockets
modified:
dcpp/Socket.cpp
--
lp:dcplusplus
https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk
Your team Dcplusplus-team is subscribed to branch lp:dcplusplus.
To unsubscribe from this branch go to https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk/+edit-subscription
=== modified file 'dcpp/Socket.cpp'
--- dcpp/Socket.cpp 2011-12-06 18:31:57 +0000
+++ dcpp/Socket.cpp 2011-12-06 19:51:07 +0000
@@ -278,10 +278,11 @@
// there's no way in ADC to have different ports for v4 and v6 TCP sockets
uint16_t ret = 0;
- string error;
+
+ addrinfo_p ai(nullptr, nullptr);
if(!v4only) {
- auto ai = resolveAddr(localIp6, port, AF_INET6, AI_PASSIVE | AI_ADDRCONFIG);
+ try { ai = resolveAddr(localIp6, port, AF_INET6, AI_PASSIVE | AI_ADDRCONFIG); } catch(const SocketException&) { }
for(auto a = ai.get(); a && !sock6.valid(); a = a->ai_next) {
try {
create(*a);
@@ -296,13 +297,11 @@
if(type == TYPE_TCP) {
check([&] { return ::listen(sock6, 20); });
}
- } catch(const SocketException& e) {
- error = e.getError();
- }
+ } catch(const SocketException&) { }
}
}
- auto ai = resolveAddr(localIp4, port, AF_INET, AI_PASSIVE | AI_ADDRCONFIG);
+ try { ai = resolveAddr(localIp4, port, AF_INET, AI_PASSIVE | AI_ADDRCONFIG); } catch(const SocketException&) { }
for(auto a = ai.get(); a && !sock4.valid(); a = a->ai_next) {
try {
create(*a);
@@ -317,13 +316,11 @@
if(type == TYPE_TCP) {
check([&] { return ::listen(sock4, 20); });
}
- } catch(const SocketException& e) {
- error = e.getError();
- }
+ } catch(const SocketException&) { }
}
if(ret == 0) {
- throw SocketException(error.empty() ? _("Could not open port for listening") : error);
+ throw SocketException(_("Could not open port for listening"));
}
return Util::toString(ntohs(ret));
}