From e4a3d745129161bb000c0010ae5361c1b06324d8 Mon Sep 17 00:00:00 2001 From: bebopagogo Date: Fri, 27 Dec 2019 19:18:02 -0500 Subject: [PATCH] Win32 tweaks to normCast example --- examples/normCast.cpp | 52 +++++------ examples/normClient.cpp | 25 ++--- makefiles/win32/Norm.sln | 34 ++++++- makefiles/win32/norm/norm.vcxproj | 121 ++++++++++++++++++++++++ makefiles/win32/normCast.vcxproj | 150 ++++++++++++++++++++++++++++++ 5 files changed, 337 insertions(+), 45 deletions(-) create mode 100644 makefiles/win32/normCast.vcxproj diff --git a/examples/normCast.cpp b/examples/normCast.cpp index d864677..81f0743 100644 --- a/examples/normCast.cpp +++ b/examples/normCast.cpp @@ -85,10 +85,18 @@ class NormCaster unsigned long GetSentCount() {return sent_count;} - // Receiver methods void SetRxCacheDirectory(const char* path) - {strncpy(rx_cache_path, path, PATH_MAX);} + { + strncpy(rx_cache_path, path, PATH_MAX); + unsigned int len = strlen(rx_cache_path); + if (PROTO_PATH_DELIMITER != rx_cache_path[len - 1]) + { + if (PATH_MAX == len) len--; + rx_cache_path[len] = PROTO_PATH_DELIMITER; + rx_cache_path[len + 1] = '\0'; + } + } const char* GetRxCacheDirectory() const {return rx_cache_path;} @@ -231,7 +239,6 @@ void NormCaster::SetNormCongestionControl(CCMode ccMode) bool NormCaster::Start(bool sender, bool receiver) { - fprintf(stderr, "enter NormCaster::Start() ...\n"); // TBD - make these command-line accessible unsigned int bufferSize = 64*1024*1024; unsigned int segmentSize = 1400; @@ -242,7 +249,6 @@ bool NormCaster::Start(bool sender, bool receiver) norm_tx_segment_size = segmentSize; - TRACE("NormCaster::Start(%d, %d) ...\n", sender, receiver); if (receiver) { if (!NormStartReceiver(norm_session, bufferSize)) @@ -403,7 +409,7 @@ bool NormCaster::EnqueueFileObject() char nameInfo[PATH_MAX + 1]; strncpy(nameInfo, namePtr, nameLen); // Normalize path delimiters to '/' for transfer - for (int i = 0; i < nameLen; i++) + for (unsigned int i = 0; i < nameLen; i++) { if (PROTO_PATH_DELIMITER == nameInfo[i]) nameInfo[i] = '/'; @@ -554,7 +560,7 @@ void NormCaster::HandleNormEvent(const NormEvent& event) if ('/' == fileName[i]) fileName[i] = PROTO_PATH_DELIMITER; } - TRACE("got info renaming to \"%s\" ...\n", fileName); + TRACE("got info renaming to: %s\n", fileName); if (!NormFileRename(event.object, fileName)) perror("normCast: rx file rename error"); break; @@ -591,7 +597,7 @@ void Usage() int main(int argc, char* argv[]) { - // REQUIRED parameters initiailization + // REQUIRED parameters initiailization NormNodeId nodeId = NORM_NODE_NONE; bool send = false; bool recv = false; @@ -615,8 +621,6 @@ int main(int argc, char* argv[]) double txloss = 0.0; bool loopback = false; - TRACE("parsing command-line ...\n"); - NormCaster normCast; // Parse command-line @@ -861,30 +865,20 @@ int main(int argc, char* argv[]) return -1; } - TRACE("calling NormCreateInstance() ...\n"); - - // TBD - should provide more error checking of calls + // TBD - should provide more error checking of calls NormInstanceHandle normInstance = NormCreateInstance(); - TRACE("calling NormSetDebugLevel() ...\n"); - NormSetDebugLevel(debugLevel); + NormSetDebugLevel(debugLevel); if (NULL != debugLog) - { - TRACE("calling NormOpenDebugLog() ...\n"); NormOpenDebugLog(normInstance, debugLog); - } - TRACE("calling NormSetCacheDirectory() (recv:%d) ...\n", recv); - // TBD - enhance NORM to support per-session or perhaps per-sender rx cache directories? + // TBD - enhance NORM to support per-session or perhaps per-sender rx cache directories? if (recv) NormSetCacheDirectory(normInstance, normCast.GetRxCacheDirectory()); - TRACE("calling SetLoopback() ...\n"); - normCast.SetLoopback(loopback); - TRACE("calling SetFlushing() ...\n"); + normCast.SetLoopback(loopback); normCast.SetFlushing(flushing); - TRACE("calling OpenNormSession() ...\n"); - if (!normCast.OpenNormSession(normInstance, sessionAddr, sessionPort, (NormNodeId)nodeId)) + if (!normCast.OpenNormSession(normInstance, sessionAddr, sessionPort, (NormNodeId)nodeId)) { fprintf(stderr, "normCast error: unable to open NORM session\n"); NormDestroyInstance(normInstance); @@ -905,12 +899,10 @@ int main(int argc, char* argv[]) if (trace) normCast.SetNormMessageTrace(true); - TRACE("calling Start() ...\n"); - // TBD - set NORM session parameters + // TBD - set NORM session parameters normCast.Start(send, recv); - TRACE("calling SendFiles() ...\n"); - if (normCast.TxFilePending()) normCast.SendFiles(); + if (normCast.TxFilePending()) normCast.SendFiles(); #ifdef WIN32 //Win32InputHandler inputHandler; @@ -926,7 +918,6 @@ int main(int argc, char* argv[]) FD_ZERO(&fdsetInput); #endif // if/else WIN32/UNIX - TRACE("entering main loop ...\n"); while (normCast.IsRunning()) { // TBD - could add "stdin" as a descriptor to monitor @@ -935,8 +926,7 @@ int main(int argc, char* argv[]) bool normEventPending = false; bool inputEventPending = false; #ifdef WIN32 - TRACE("calling MsgWaitForMultipleObjectsEx() ...\n"); - DWORD handleCount = inputNeeded ? 2 : 1; + DWORD handleCount = inputNeeded ? 2 : 1; DWORD waitStatus = MsgWaitForMultipleObjectsEx(handleCount, // number of handles in array handleArray, // object-handle array diff --git a/examples/normClient.cpp b/examples/normClient.cpp index 7491cbc..86e8d47 100644 --- a/examples/normClient.cpp +++ b/examples/normClient.cpp @@ -136,11 +136,21 @@ int main(int argc, char* argv[]) } NormInstanceHandle instance = NormCreateInstance(); + NormSocketHandle normSocket = NormOpen(instance); + + if (trace) + { + NormSetMessageTrace(NormGetSocketSession(normSocket), true); + if (NULL != groupAddrPtr) + NormSetMessageTrace(NormGetSocketMulticastSession(normSocket), true); + } + if (0 != debugLevel) NormSetDebugLevel(debugLevel); + + //NormSetDebugLevel(3); + //NormSetMessageTrace(NormGetSocketSession(normSocket), true); // Initate connection to server ... - fprintf(stderr, "normClient: connecting to %s/%hu ...\n", serverAddr, serverPort); - NormSocketHandle normSocket = NormOpen(instance); - + fprintf(stderr, "normClient: connecting to %s/%hu ...\n", serverAddr, serverPort); // setting 'localPort' param here to zero lets an ephemeral port be picked NormConnect(normSocket, serverAddr, serverPort, 0, groupAddrPtr, clientId); /* // Optional code to test NormWrite() immediately after NormConnect() call @@ -150,16 +160,7 @@ int main(int argc, char* argv[]) NormWrite(normSocket, helloStr, helloLen); NormFlush(normSocket);*/ - if (trace) - { - NormSetMessageTrace(NormGetSocketSession(normSocket), true); - if (NULL != groupAddrPtr) - NormSetMessageTrace(NormGetSocketMulticastSession(normSocket), true); - } - if (0 != debugLevel) NormSetDebugLevel(debugLevel); - //NormSetDebugLevel(3); - //NormSetMessageTrace(NormGetSocketSession(normSocket), true); #ifdef WIN32 HANDLE hStdout = GetStdHandle(STD_OUTPUT_HANDLE); diff --git a/makefiles/win32/Norm.sln b/makefiles/win32/Norm.sln index 4fb993f..67a88c9 100644 --- a/makefiles/win32/Norm.sln +++ b/makefiles/win32/Norm.sln @@ -1,6 +1,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Express 2013 for Windows Desktop -VisualStudioVersion = 12.0.30723.0 +# Visual Studio 15 +VisualStudioVersion = 15.0.27428.2002 MinimumVisualStudioVersion = 10.0.40219.1 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "NormLib", "NormLib.vcxproj", "{D7B0023C-8798-4918-8DA0-05C9054D70B9}" EndProject @@ -14,36 +14,66 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "npc", "npc.vcxproj", "{7BF4 EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Protokit", "..\..\protolib\makefiles\win32\Protokit.vcxproj", "{DE94F096-A09B-44B6-8EFE-C7BF1F65C4C9}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "normCast", "normCast.vcxproj", "{7B453DAC-67A1-48AB-B6D4-BA25F698A158}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 Release|Win32 = Release|Win32 + Release|x64 = Release|x64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {D7B0023C-8798-4918-8DA0-05C9054D70B9}.Debug|Win32.ActiveCfg = Debug|Win32 {D7B0023C-8798-4918-8DA0-05C9054D70B9}.Debug|Win32.Build.0 = Debug|Win32 + {D7B0023C-8798-4918-8DA0-05C9054D70B9}.Debug|x64.ActiveCfg = Debug|Win32 {D7B0023C-8798-4918-8DA0-05C9054D70B9}.Release|Win32.ActiveCfg = Release|Win32 {D7B0023C-8798-4918-8DA0-05C9054D70B9}.Release|Win32.Build.0 = Release|Win32 + {D7B0023C-8798-4918-8DA0-05C9054D70B9}.Release|x64.ActiveCfg = Release|Win32 {6E1308A6-D40F-489E-A4F1-40D859380D64}.Debug|Win32.ActiveCfg = Debug|Win32 {6E1308A6-D40F-489E-A4F1-40D859380D64}.Debug|Win32.Build.0 = Debug|Win32 + {6E1308A6-D40F-489E-A4F1-40D859380D64}.Debug|x64.ActiveCfg = Debug|x64 + {6E1308A6-D40F-489E-A4F1-40D859380D64}.Debug|x64.Build.0 = Debug|x64 {6E1308A6-D40F-489E-A4F1-40D859380D64}.Release|Win32.ActiveCfg = Release|Win32 {6E1308A6-D40F-489E-A4F1-40D859380D64}.Release|Win32.Build.0 = Release|Win32 + {6E1308A6-D40F-489E-A4F1-40D859380D64}.Release|x64.ActiveCfg = Release|Win32 + {6E1308A6-D40F-489E-A4F1-40D859380D64}.Release|x64.Build.0 = Release|Win32 {32CF83E0-D2E0-4E43-8F7B-72BD0AB64647}.Debug|Win32.ActiveCfg = Debug|Win32 {32CF83E0-D2E0-4E43-8F7B-72BD0AB64647}.Debug|Win32.Build.0 = Debug|Win32 + {32CF83E0-D2E0-4E43-8F7B-72BD0AB64647}.Debug|x64.ActiveCfg = Debug|Win32 {32CF83E0-D2E0-4E43-8F7B-72BD0AB64647}.Release|Win32.ActiveCfg = Release|Win32 {32CF83E0-D2E0-4E43-8F7B-72BD0AB64647}.Release|Win32.Build.0 = Release|Win32 + {32CF83E0-D2E0-4E43-8F7B-72BD0AB64647}.Release|x64.ActiveCfg = Release|Win32 {182006F3-188F-466E-89FE-8421C0478691}.Debug|Win32.ActiveCfg = Debug|Win32 {182006F3-188F-466E-89FE-8421C0478691}.Debug|Win32.Build.0 = Debug|Win32 + {182006F3-188F-466E-89FE-8421C0478691}.Debug|x64.ActiveCfg = Debug|Win32 {182006F3-188F-466E-89FE-8421C0478691}.Release|Win32.ActiveCfg = Release|Win32 {182006F3-188F-466E-89FE-8421C0478691}.Release|Win32.Build.0 = Release|Win32 + {182006F3-188F-466E-89FE-8421C0478691}.Release|x64.ActiveCfg = Release|Win32 {7BF4525B-9185-4296-A2BF-FFE77BB66EAF}.Debug|Win32.ActiveCfg = Debug|Win32 + {7BF4525B-9185-4296-A2BF-FFE77BB66EAF}.Debug|Win32.Build.0 = Debug|Win32 + {7BF4525B-9185-4296-A2BF-FFE77BB66EAF}.Debug|x64.ActiveCfg = Debug|Win32 {7BF4525B-9185-4296-A2BF-FFE77BB66EAF}.Release|Win32.ActiveCfg = Release|Win32 + {7BF4525B-9185-4296-A2BF-FFE77BB66EAF}.Release|x64.ActiveCfg = Release|Win32 {DE94F096-A09B-44B6-8EFE-C7BF1F65C4C9}.Debug|Win32.ActiveCfg = Debug|Win32 {DE94F096-A09B-44B6-8EFE-C7BF1F65C4C9}.Debug|Win32.Build.0 = Debug|Win32 + {DE94F096-A09B-44B6-8EFE-C7BF1F65C4C9}.Debug|x64.ActiveCfg = Debug|x64 + {DE94F096-A09B-44B6-8EFE-C7BF1F65C4C9}.Debug|x64.Build.0 = Debug|x64 {DE94F096-A09B-44B6-8EFE-C7BF1F65C4C9}.Release|Win32.ActiveCfg = Release|Win32 {DE94F096-A09B-44B6-8EFE-C7BF1F65C4C9}.Release|Win32.Build.0 = Release|Win32 + {DE94F096-A09B-44B6-8EFE-C7BF1F65C4C9}.Release|x64.ActiveCfg = Release|Win32 + {DE94F096-A09B-44B6-8EFE-C7BF1F65C4C9}.Release|x64.Build.0 = Release|Win32 + {7B453DAC-67A1-48AB-B6D4-BA25F698A158}.Debug|Win32.ActiveCfg = Debug|Win32 + {7B453DAC-67A1-48AB-B6D4-BA25F698A158}.Debug|Win32.Build.0 = Debug|Win32 + {7B453DAC-67A1-48AB-B6D4-BA25F698A158}.Debug|x64.ActiveCfg = Debug|Win32 + {7B453DAC-67A1-48AB-B6D4-BA25F698A158}.Release|Win32.ActiveCfg = Release|Win32 + {7B453DAC-67A1-48AB-B6D4-BA25F698A158}.Release|Win32.Build.0 = Release|Win32 + {7B453DAC-67A1-48AB-B6D4-BA25F698A158}.Release|x64.ActiveCfg = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {82C71DFA-363B-4FC0-85AE-FA8269044807} + EndGlobalSection EndGlobal diff --git a/makefiles/win32/norm/norm.vcxproj b/makefiles/win32/norm/norm.vcxproj index 9c8be51..9034b1c 100755 --- a/makefiles/win32/norm/norm.vcxproj +++ b/makefiles/win32/norm/norm.vcxproj @@ -5,10 +5,18 @@ Debug Win32 + + Debug + x64 + Release Win32 + + Release + x64 + {6E1308A6-D40F-489E-A4F1-40D859380D64} @@ -21,12 +29,24 @@ false MultiByte + + Application + v141 + false + MultiByte + Application v141 false MultiByte + + Application + v141 + false + MultiByte + @@ -34,10 +54,18 @@ + + + + + + + + <_ProjectFileVersion>11.0.61030.0 @@ -47,11 +75,17 @@ .\Debug\ false + + false + .\Release\ .\Release\ false + + false + _DEBUG;%(PreprocessorDefinitions) @@ -94,6 +128,49 @@ MachineX86 + + + _DEBUG;%(PreprocessorDefinitions) + true + true + .\Debug/norm.tlb + + + + + /vmg %(AdditionalOptions) + Disabled + ..\..\..\include;..\..\..\protolib\include;%(AdditionalIncludeDirectories) + _CONSOLE,_DEBUG;PROTO_DEBUG;HAVE_IPV6;HAVE_ASSERT;WIN32;_CRT_SECURE_NO_WARNINGS;_WINDOWS;%(PreprocessorDefinitions) + EnableFastChecks + MultiThreadedDebugDLL + + + .\Debug/norm.pch + .\Debug/ + .\Debug/ + .\Debug/ + Level3 + true + ProgramDatabase + Default + + + _DEBUG;%(PreprocessorDefinitions) + 0x0409 + + + iphlpapi.lib;ws2_32.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + .\Debug/norm.exe + true + true + .\Debug/norm.pdb + Windows + false + + + + NDEBUG;%(PreprocessorDefinitions) @@ -137,6 +214,50 @@ MachineX86 + + + NDEBUG;%(PreprocessorDefinitions) + true + true + .\Release/norm.tlb + + + + + /vmg %(AdditionalOptions) + MaxSpeed + OnlyExplicitInline + ..\..\..\include;..\..\..\protolib\include;%(AdditionalIncludeDirectories) + _CONSOLE,NDEBUG;PROTO_DEBUG;HAVE_IPV6;HAVE_ASSERT;WIN32;_WINDOWS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + true + MultiThreadedDLL + true + + + .\Release/norm.pch + .\Release/ + .\Release/ + .\Release/ + true + Level3 + true + Default + + + NDEBUG;%(PreprocessorDefinitions) + 0x0409 + + + iphlpapi.lib;ws2_32.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + .\Release/norm.exe + true + .\Release/norm.pdb + Windows + false + + + + diff --git a/makefiles/win32/normCast.vcxproj b/makefiles/win32/normCast.vcxproj new file mode 100644 index 0000000..d086116 --- /dev/null +++ b/makefiles/win32/normCast.vcxproj @@ -0,0 +1,150 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + {7B453DAC-67A1-48AB-B6D4-BA25F698A158} + normTest + 10.0.16299.0 + + + + Application + v141 + false + MultiByte + + + Application + v141 + false + MultiByte + + + + + + + + + + + + + + + <_ProjectFileVersion>11.0.50727.1 + + + .\Debug\ + .\Debug\ + + + + .\Release\ + .\Release\ + false + false + + + + .\Debug/normTest.tlb + + + + Disabled + ..\..\include;..\..\protolib\include;%(AdditionalIncludeDirectories) + NORM_USE_DLL;PROTO_DEBUG;HAVE_ASSERT;WIN32;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + EnableFastChecks + MultiThreadedDebugDLL + true + + .\Debug/normTest.pch + .\Debug/ + .\Debug/ + .\Debug/ + Level3 + true + EditAndContinue + Default + + + _DEBUG;%(PreprocessorDefinitions) + 0x0409 + + + iphlpapi.lib;ws2_32.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + .\Debug/normCast.exe + true + ./;%(AdditionalLibraryDirectories) + true + .\Debug/normTest.pdb + Console + false + + MachineX86 + + + + + .\Release/normTest.tlb + + + + MaxSpeed + OnlyExplicitInline + ..\..\include;..\..\protolib\include;%(AdditionalIncludeDirectories) + NORM_USE_DLL;PROTO_DEBUG;WIN32;HAVE_ASSERT;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + true + MultiThreadedDLL + true + + .\Release/normTest.pch + .\Release/ + .\Release/ + .\Release/ + Level3 + true + ProgramDatabase + Default + + + NDEBUG;%(PreprocessorDefinitions) + 0x0409 + + + iphlpapi.lib;ws2_32.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + .\Release/normCast.exe + true + .\Release/normTest.pdb + Console + false + + MachineX86 + + + + + + + + {de94f096-a09b-44b6-8efe-c7bf1f65c4c9} + false + + + {182006f3-188f-466e-89fe-8421c0478691} + false + + + + + + \ No newline at end of file