From dba5e3f1f1ececf1cda25bc5ffa396bfcb2817df Mon Sep 17 00:00:00 2001 From: Nicolas Date: Thu, 8 Mar 2018 22:35:06 -0300 Subject: [PATCH] Add timeout to smo sockets (#1651) * Add timeout to smo sockets Without this sometimes an attempt at a connection hangs and completely stops the program (VERY annoying in fullscreen) in the recv function. * Fix typo from previous commit * Change smo timeout to 5 --- src/ezsockets.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/ezsockets.cpp b/src/ezsockets.cpp index 5f3cabfc09..a90db503e9 100644 --- a/src/ezsockets.cpp +++ b/src/ezsockets.cpp @@ -173,6 +173,10 @@ bool EzSockets::create(EzSockets_Proto Protocol, int Type) } data->sock = socket(AF_INET, Type, realproto); + if (data->sock > SOCKET_NONE) { + struct timeval tv = { 5, 0 }; + setsockopt(data->sock, SOL_SOCKET, SO_RCVTIMEO, (const char *)&tv, sizeof(struct timeval)); + } lastCode = data->sock; return data->sock > SOCKET_NONE; // Socket must be Greater than 0 }