From 424f2fcef528a7465fb3cac206f358b1e2391fa5 Mon Sep 17 00:00:00 2001 From: zsilencer Date: Mon, 24 Jul 2017 11:24:19 -0600 Subject: [PATCH] Fix #5984: Allow socket binding to same port after crash --- distribution/changelog.txt | 1 + src/openrct2/network/TcpSocket.cpp | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/distribution/changelog.txt b/distribution/changelog.txt index 3637af94d4..bfa9bc1ecd 100644 --- a/distribution/changelog.txt +++ b/distribution/changelog.txt @@ -13,6 +13,7 @@ - Fix: [#5920] Placing guest spawn doesn't do anything every 3rd click - Fix: [#5939] Crash when importing 'Six Flags Santa Fe'. - Fix: [#5977] Custom music files not showing up in music list +- Fix: [#5984] Allow socket binding to same port after crash - Improved: [#4301] Leading and trailing whitespace in player name is now removed. - Improved: [#5859] OpenGL rendering performance - Improved: [#5863] Switching drawing engines no longer requires the application to restart. diff --git a/src/openrct2/network/TcpSocket.cpp b/src/openrct2/network/TcpSocket.cpp index 31d1da73ec..4c00859902 100644 --- a/src/openrct2/network/TcpSocket.cpp +++ b/src/openrct2/network/TcpSocket.cpp @@ -147,6 +147,12 @@ public: log_error("IPV6_V6ONLY failed. %d", LAST_SOCKET_ERROR()); } + value = 1; + if (setsockopt(_socket, SOL_SOCKET, SO_REUSEADDR, (const char*)&value, sizeof(value)) != 0) + { + log_error("SO_REUSEADDR failed. %d", LAST_SOCKET_ERROR()); + } + try { // Bind to address:port and listen