From 71753743504660e73a25ec29c6328a0818f8fd42 Mon Sep 17 00:00:00 2001
From: Edward Richardson <Edward850@crantime.org>
Date: Sun, 5 Oct 2014 19:46:34 +1300
Subject: [PATCH] Keep gateway sockets open during handshake

---
 src/i_net.cpp | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/src/i_net.cpp b/src/i_net.cpp
index 3ec9d78813..6fdcb52ba9 100644
--- a/src/i_net.cpp
+++ b/src/i_net.cpp
@@ -110,6 +110,7 @@ const char *neterror (void);
 enum
 {
 	PRE_CONNECT,			// Sent from guest to host for initial connection
+	PRE_KEEPALIVE,
 	PRE_DISCONNECT,			// Sent from guest that aborts the game
 	PRE_ALLHERE,			// Sent from host to guest when everybody has connected
 	PRE_CONACK,				// Sent from host to guest to acknowledge PRE_CONNECT receipt
@@ -548,10 +549,15 @@ bool Host_CheckForConnects (void *userdata)
 				SendConAck (doomcom.numnodes, numplayers);
 			}
 			break;
+
+		case PRE_KEEPALIVE:
+			break;
 		}
 	}
 	if (doomcom.numnodes < numplayers)
 	{
+		// Send message to everyone as a keepalive
+		SendConAck(doomcom.numnodes, numplayers);
 		return false;
 	}
 
@@ -822,6 +828,10 @@ bool Guest_WaitForOthers (void *userdata)
 		}
 	}
 
+	packet.Fake = PRE_FAKE;
+	packet.Message = PRE_KEEPALIVE;
+	PreSend(&packet, 2, &sendaddress[1]);
+
 	return false;
 }