diff --git a/src/i_tcp.c b/src/i_tcp.c
index 9febd56f019e253a024f4e3b170852ab0e6606ac..6a21278662b4f914eaab6661680ac2f55501ec5a 100644
--- a/src/i_tcp.c
+++ b/src/i_tcp.c
@@ -781,9 +781,13 @@ static void SOCK_Send(void)
 			&clientaddress[doomcom->remotenode].any, d);
 	}
 
-	if (c == ERRSOCKET && errno != ECONNREFUSED && errno != EWOULDBLOCK)
-		I_Error("SOCK_Send, error sending to node %d (%s) #%u: %s", doomcom->remotenode,
-			SOCK_GetNodeAddress(doomcom->remotenode), errno, strerror(errno));
+	if (c == ERRSOCKET)
+	{
+		int e = errno; // save error code so it can't be modified later
+		if (e != ECONNREFUSED && e != EWOULDBLOCK)
+			I_Error("SOCK_Send, error sending to node %d (%s) #%u: %s", doomcom->remotenode,
+				SOCK_GetNodeAddress(doomcom->remotenode), e, strerror(e));
+	}
 }
 #endif