summaryrefslogtreecommitdiff
path: root/src/network/core
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2009-04-08 11:57:00 +0000
committerrubidium <rubidium@openttd.org>2009-04-08 11:57:00 +0000
commit18146572b0a0cbb3eb89738f633fefd903df9692 (patch)
tree0a44b2d39a73c4bb3e6104a1b1cd376af8905410 /src/network/core
parentc2152fa31fa0ec8d735b53dfe544b84a9551c740 (diff)
downloadopenttd-18146572b0a0cbb3eb89738f633fefd903df9692.tar.xz
(svn r15980) -Codechange: don't try to bind to the same socket twice; it's quite pointless.
Diffstat (limited to 'src/network/core')
-rw-r--r--src/network/core/address.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/network/core/address.cpp b/src/network/core/address.cpp
index aafa7947c..ba81a6c0d 100644
--- a/src/network/core/address.cpp
+++ b/src/network/core/address.cpp
@@ -187,6 +187,13 @@ SOCKET NetworkAddress::Resolve(int family, int socktype, int flags, SocketList *
SOCKET sock = INVALID_SOCKET;
for (struct addrinfo *runp = ai; runp != NULL; runp = runp->ai_next) {
+ /* When we are binding to multiple sockets, make sure we do not
+ * connect to one with exactly the same address twice. That's
+ * ofcourse totally unneeded ;) */
+ if (sockets != NULL) {
+ NetworkAddress address(runp->ai_addr, runp->ai_addrlen);
+ if (sockets->Find(address) != sockets->End()) continue;
+ }
sock = func(runp);
if (sock == INVALID_SOCKET) continue;