From 4e87b8ea9ac691eb7b91802ba85ea664ecb0c7ff Mon Sep 17 00:00:00 2001 From: Richard Harrison Date: Thu, 2 Feb 2017 06:22:35 +0100 Subject: [PATCH] Multiplay: Improve log message handling for win32. --- src/MultiPlayer/multiplaymgr.cxx | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/MultiPlayer/multiplaymgr.cxx b/src/MultiPlayer/multiplaymgr.cxx index 64cf5ec5f..c807b984d 100644 --- a/src/MultiPlayer/multiplaymgr.cxx +++ b/src/MultiPlayer/multiplaymgr.cxx @@ -51,6 +51,9 @@ #include "MPServerResolver.hxx" #include +#if defined(_MSC_VER) || defined(__MINGW32__) +#include +#endif using namespace std; #define MAX_PACKET_SIZE 1200 @@ -949,7 +952,7 @@ FGMultiplayMgr::SendMyPosition(const FGExternalMotionData& motionInfo) } if (msgLen>0) mSocket->sendto(msgBuf.Msg, msgLen, 0, &mServer); - SG_LOG(SG_NETWORK, SG_DEBUG, "FGMultiplayMgr::SendMyPosition"); + SG_LOG(SG_NETWORK, SG_BULK, "FGMultiplayMgr::SendMyPosition"); } // FGMultiplayMgr::SendMyPosition() ////////////////////////////////////////////////////////////////////// @@ -1051,9 +1054,17 @@ FGMultiplayMgr::update(double dt) if (RecvStatus<0) { - SG_LOG(SG_NETWORK, SG_DEBUG, "FGMultiplayMgr::MP_ProcessData - Unable to receive data. " +#ifdef _WIN32 + if (::WSAGetLastError() != WSAEWOULDBLOCK) // this is normal on a receive when there is no data + { + // with Winsock the error will not be the actual problem. + SG_LOG(SG_NETWORK, SG_DEBUG, "FGMultiplayMgr::MP_ProcessData - Unable to receive data. WSAGetLastError=" << ::WSAGetLastError()); + } +#else + SG_LOG(SG_NETWORK, SG_DEBUG, "FGMultiplayMgr::MP_ProcessData - Unable to receive data. " << strerror(errno) << "(errno " << errno << ")"); - break; +#endif + break; } // status is positive: bytes received