From e90c146e6f59122df1d12dc794145a6e7620cee6 Mon Sep 17 00:00:00 2001 From: HEYAHONG <2229388563@qq.com> Date: Fri, 10 Jan 2025 16:57:31 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DCygwin=E4=B8=8B=E7=9A=84?= =?UTF-8?q?=E5=A5=97=E6=8E=A5=E5=AD=97=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hcppbox/HCPPSocket.cpp | 10 ++++++++ hcppbox/HCPPSocketCygwinHelper.cpp | 37 ++++++++++++++++++++++++++++++ hcppbox/ReadMe.md | 11 +++++++++ 3 files changed, 58 insertions(+) create mode 100644 hcppbox/HCPPSocketCygwinHelper.cpp diff --git a/hcppbox/HCPPSocket.cpp b/hcppbox/HCPPSocket.cpp index 2386841..77ea8f0 100644 --- a/hcppbox/HCPPSocket.cpp +++ b/hcppbox/HCPPSocket.cpp @@ -8,6 +8,10 @@ **************************************************************/ #include "HCPPSocket.h" #ifdef HCPPSOCKET_HAVE_SOCKET +#ifdef __CYGWIN__ +void HCPPSocketCygwinHelperStartup(); +void HCPPSocketCygwinHelperCleanup(); +#endif // __CYGWIN__ static class socket_manager { public: @@ -28,12 +32,18 @@ static class socket_manager } } #endif +#ifdef __CYGWIN__ + HCPPSocketCygwinHelperStartup(); +#endif // __CYGWIN__ } ~socket_manager() { #ifdef WIN32 WSACleanup(); #endif +#ifdef __CYGWIN__ + HCPPSocketCygwinHelperCleanup(); +#endif // __CYGWIN__ } } g_socket_manager; diff --git a/hcppbox/HCPPSocketCygwinHelper.cpp b/hcppbox/HCPPSocketCygwinHelper.cpp new file mode 100644 index 0000000..37fb50d --- /dev/null +++ b/hcppbox/HCPPSocketCygwinHelper.cpp @@ -0,0 +1,37 @@ +/*************************************************************** + * Name: HCPPSocketCygwinHelper.cpp + * Purpose: HCPPSocketCygwinHelper + * Author: HYH (hyhsystem.cn) + * Created: 2024-01-10 + * Copyright: HYH (hyhsystem.cn) + * License: MIT + **************************************************************/ + +#ifdef __CYGWIN__ + +#include "winsock2.h" +#include "windows.h" + +void HCPPSocketCygwinHelperStartup() +{ + WSADATA wsaData; + const WORD VersionList[]= + { + (2 << 8) | 2, + (1 << 8) | 1, + }; + for(size_t i=0; i