diff --git a/acl_cpp_vc2019.sln b/acl_cpp_vc2019.sln
index 8e3d0f682..e24689637 100644
--- a/acl_cpp_vc2019.sln
+++ b/acl_cpp_vc2019.sln
@@ -62,6 +62,26 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WinFiber", "lib_fiber\sampl
{FE724EF7-3763-4E78-BDF5-BCBC075719FD} = {FE724EF7-3763-4E78-BDF5-BCBC075719FD}
EndProjectSection
EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "fiber_gui", "fiber_gui", "{1CB30F2E-2587-43E7-A3CF-787783FB6924}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HttpGet", "lib_fiber\samples-gui\HttpGet\HttpGet.vcxproj", "{FE7E9F00-7F46-4072-8B29-A4E915259CDE}"
+ ProjectSection(ProjectDependencies) = postProject
+ {F2479E2C-7267-436C-A1F1-A63B39E7CB30} = {F2479E2C-7267-436C-A1F1-A63B39E7CB30}
+ {6EC1F44E-6A6A-48E9-B699-D7E89B63C8DC} = {6EC1F44E-6A6A-48E9-B699-D7E89B63C8DC}
+ {AD99B75A-40BF-46DC-844B-23417FDC8690} = {AD99B75A-40BF-46DC-844B-23417FDC8690}
+ {B40213C2-507C-4C7F-A6E1-B850C9BDC27B} = {B40213C2-507C-4C7F-A6E1-B850C9BDC27B}
+ {FE724EF7-3763-4E78-BDF5-BCBC075719FD} = {FE724EF7-3763-4E78-BDF5-BCBC075719FD}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "EchoServer", "lib_fiber\samples-gui\EchoServer\EchoServer.vcxproj", "{30A882E6-CF13-494F-9132-CE15E040B9DE}"
+ ProjectSection(ProjectDependencies) = postProject
+ {F2479E2C-7267-436C-A1F1-A63B39E7CB30} = {F2479E2C-7267-436C-A1F1-A63B39E7CB30}
+ {6EC1F44E-6A6A-48E9-B699-D7E89B63C8DC} = {6EC1F44E-6A6A-48E9-B699-D7E89B63C8DC}
+ {AD99B75A-40BF-46DC-844B-23417FDC8690} = {AD99B75A-40BF-46DC-844B-23417FDC8690}
+ {B40213C2-507C-4C7F-A6E1-B850C9BDC27B} = {B40213C2-507C-4C7F-A6E1-B850C9BDC27B}
+ {FE724EF7-3763-4E78-BDF5-BCBC075719FD} = {FE724EF7-3763-4E78-BDF5-BCBC075719FD}
+ EndProjectSection
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Mixed Platforms = Debug|Mixed Platforms
@@ -328,6 +348,66 @@ Global
{141DDEA4-DDEF-4D7E-9FE1-5FEFE0D95222}.Template|Win32.Build.0 = Debug|Win32
{141DDEA4-DDEF-4D7E-9FE1-5FEFE0D95222}.Template|x64.ActiveCfg = Debug|x64
{141DDEA4-DDEF-4D7E-9FE1-5FEFE0D95222}.Template|x64.Build.0 = Debug|x64
+ {FE7E9F00-7F46-4072-8B29-A4E915259CDE}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
+ {FE7E9F00-7F46-4072-8B29-A4E915259CDE}.Debug|Mixed Platforms.Build.0 = Debug|Win32
+ {FE7E9F00-7F46-4072-8B29-A4E915259CDE}.Debug|Win32.ActiveCfg = Debug|Win32
+ {FE7E9F00-7F46-4072-8B29-A4E915259CDE}.Debug|Win32.Build.0 = Debug|Win32
+ {FE7E9F00-7F46-4072-8B29-A4E915259CDE}.Debug|x64.ActiveCfg = Debug|x64
+ {FE7E9F00-7F46-4072-8B29-A4E915259CDE}.Debug|x64.Build.0 = Debug|x64
+ {FE7E9F00-7F46-4072-8B29-A4E915259CDE}.DebugDll|Mixed Platforms.ActiveCfg = Debug|Win32
+ {FE7E9F00-7F46-4072-8B29-A4E915259CDE}.DebugDll|Mixed Platforms.Build.0 = Debug|Win32
+ {FE7E9F00-7F46-4072-8B29-A4E915259CDE}.DebugDll|Win32.ActiveCfg = Debug|Win32
+ {FE7E9F00-7F46-4072-8B29-A4E915259CDE}.DebugDll|Win32.Build.0 = Debug|Win32
+ {FE7E9F00-7F46-4072-8B29-A4E915259CDE}.DebugDll|x64.ActiveCfg = Debug|x64
+ {FE7E9F00-7F46-4072-8B29-A4E915259CDE}.DebugDll|x64.Build.0 = Debug|x64
+ {FE7E9F00-7F46-4072-8B29-A4E915259CDE}.Release|Mixed Platforms.ActiveCfg = Release|Win32
+ {FE7E9F00-7F46-4072-8B29-A4E915259CDE}.Release|Mixed Platforms.Build.0 = Release|Win32
+ {FE7E9F00-7F46-4072-8B29-A4E915259CDE}.Release|Win32.ActiveCfg = Release|Win32
+ {FE7E9F00-7F46-4072-8B29-A4E915259CDE}.Release|Win32.Build.0 = Release|Win32
+ {FE7E9F00-7F46-4072-8B29-A4E915259CDE}.Release|x64.ActiveCfg = Release|x64
+ {FE7E9F00-7F46-4072-8B29-A4E915259CDE}.Release|x64.Build.0 = Release|x64
+ {FE7E9F00-7F46-4072-8B29-A4E915259CDE}.Releasedll|Mixed Platforms.ActiveCfg = Release|Win32
+ {FE7E9F00-7F46-4072-8B29-A4E915259CDE}.Releasedll|Mixed Platforms.Build.0 = Release|Win32
+ {FE7E9F00-7F46-4072-8B29-A4E915259CDE}.Releasedll|Win32.ActiveCfg = Release|Win32
+ {FE7E9F00-7F46-4072-8B29-A4E915259CDE}.Releasedll|Win32.Build.0 = Release|Win32
+ {FE7E9F00-7F46-4072-8B29-A4E915259CDE}.Releasedll|x64.ActiveCfg = Release|x64
+ {FE7E9F00-7F46-4072-8B29-A4E915259CDE}.Releasedll|x64.Build.0 = Release|x64
+ {FE7E9F00-7F46-4072-8B29-A4E915259CDE}.Template|Mixed Platforms.ActiveCfg = Debug|Win32
+ {FE7E9F00-7F46-4072-8B29-A4E915259CDE}.Template|Mixed Platforms.Build.0 = Debug|Win32
+ {FE7E9F00-7F46-4072-8B29-A4E915259CDE}.Template|Win32.ActiveCfg = Debug|Win32
+ {FE7E9F00-7F46-4072-8B29-A4E915259CDE}.Template|Win32.Build.0 = Debug|Win32
+ {FE7E9F00-7F46-4072-8B29-A4E915259CDE}.Template|x64.ActiveCfg = Debug|x64
+ {FE7E9F00-7F46-4072-8B29-A4E915259CDE}.Template|x64.Build.0 = Debug|x64
+ {30A882E6-CF13-494F-9132-CE15E040B9DE}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
+ {30A882E6-CF13-494F-9132-CE15E040B9DE}.Debug|Mixed Platforms.Build.0 = Debug|Win32
+ {30A882E6-CF13-494F-9132-CE15E040B9DE}.Debug|Win32.ActiveCfg = Debug|Win32
+ {30A882E6-CF13-494F-9132-CE15E040B9DE}.Debug|Win32.Build.0 = Debug|Win32
+ {30A882E6-CF13-494F-9132-CE15E040B9DE}.Debug|x64.ActiveCfg = Debug|x64
+ {30A882E6-CF13-494F-9132-CE15E040B9DE}.Debug|x64.Build.0 = Debug|x64
+ {30A882E6-CF13-494F-9132-CE15E040B9DE}.DebugDll|Mixed Platforms.ActiveCfg = Debug|Win32
+ {30A882E6-CF13-494F-9132-CE15E040B9DE}.DebugDll|Mixed Platforms.Build.0 = Debug|Win32
+ {30A882E6-CF13-494F-9132-CE15E040B9DE}.DebugDll|Win32.ActiveCfg = Debug|Win32
+ {30A882E6-CF13-494F-9132-CE15E040B9DE}.DebugDll|Win32.Build.0 = Debug|Win32
+ {30A882E6-CF13-494F-9132-CE15E040B9DE}.DebugDll|x64.ActiveCfg = Debug|x64
+ {30A882E6-CF13-494F-9132-CE15E040B9DE}.DebugDll|x64.Build.0 = Debug|x64
+ {30A882E6-CF13-494F-9132-CE15E040B9DE}.Release|Mixed Platforms.ActiveCfg = Release|Win32
+ {30A882E6-CF13-494F-9132-CE15E040B9DE}.Release|Mixed Platforms.Build.0 = Release|Win32
+ {30A882E6-CF13-494F-9132-CE15E040B9DE}.Release|Win32.ActiveCfg = Release|Win32
+ {30A882E6-CF13-494F-9132-CE15E040B9DE}.Release|Win32.Build.0 = Release|Win32
+ {30A882E6-CF13-494F-9132-CE15E040B9DE}.Release|x64.ActiveCfg = Release|x64
+ {30A882E6-CF13-494F-9132-CE15E040B9DE}.Release|x64.Build.0 = Release|x64
+ {30A882E6-CF13-494F-9132-CE15E040B9DE}.Releasedll|Mixed Platforms.ActiveCfg = Release|Win32
+ {30A882E6-CF13-494F-9132-CE15E040B9DE}.Releasedll|Mixed Platforms.Build.0 = Release|Win32
+ {30A882E6-CF13-494F-9132-CE15E040B9DE}.Releasedll|Win32.ActiveCfg = Release|Win32
+ {30A882E6-CF13-494F-9132-CE15E040B9DE}.Releasedll|Win32.Build.0 = Release|Win32
+ {30A882E6-CF13-494F-9132-CE15E040B9DE}.Releasedll|x64.ActiveCfg = Release|x64
+ {30A882E6-CF13-494F-9132-CE15E040B9DE}.Releasedll|x64.Build.0 = Release|x64
+ {30A882E6-CF13-494F-9132-CE15E040B9DE}.Template|Mixed Platforms.ActiveCfg = Debug|Win32
+ {30A882E6-CF13-494F-9132-CE15E040B9DE}.Template|Mixed Platforms.Build.0 = Debug|Win32
+ {30A882E6-CF13-494F-9132-CE15E040B9DE}.Template|Win32.ActiveCfg = Debug|Win32
+ {30A882E6-CF13-494F-9132-CE15E040B9DE}.Template|Win32.Build.0 = Debug|Win32
+ {30A882E6-CF13-494F-9132-CE15E040B9DE}.Template|x64.ActiveCfg = Debug|x64
+ {30A882E6-CF13-494F-9132-CE15E040B9DE}.Template|x64.Build.0 = Debug|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -342,7 +422,10 @@ Global
{FD628E34-FBB8-4C60-8176-B770EC631CD9} = {083DCC81-9A3F-4B12-9821-2B9F52BCCF79}
{EE518BE5-94B2-4F8E-82CC-C08503BBD6B2} = {FD628E34-FBB8-4C60-8176-B770EC631CD9}
{3E725148-0807-4CBA-8FC1-7FCA46F605F3} = {FD628E34-FBB8-4C60-8176-B770EC631CD9}
- {141DDEA4-DDEF-4D7E-9FE1-5FEFE0D95222} = {FD628E34-FBB8-4C60-8176-B770EC631CD9}
+ {141DDEA4-DDEF-4D7E-9FE1-5FEFE0D95222} = {1CB30F2E-2587-43E7-A3CF-787783FB6924}
+ {1CB30F2E-2587-43E7-A3CF-787783FB6924} = {083DCC81-9A3F-4B12-9821-2B9F52BCCF79}
+ {FE7E9F00-7F46-4072-8B29-A4E915259CDE} = {1CB30F2E-2587-43E7-A3CF-787783FB6924}
+ {30A882E6-CF13-494F-9132-CE15E040B9DE} = {1CB30F2E-2587-43E7-A3CF-787783FB6924}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {40FA3A5B-123F-4EC0-9EEB-8A9C17BF573B}
diff --git a/lib_fiber/samples-gui/EchoServer/EchoServer.cpp b/lib_fiber/samples-gui/EchoServer/EchoServer.cpp
new file mode 100644
index 000000000..7758d9fbc
--- /dev/null
+++ b/lib_fiber/samples-gui/EchoServer/EchoServer.cpp
@@ -0,0 +1,113 @@
+
+// EchoServer.cpp: 定义应用程序的类行为。
+//
+
+#include "pch.h"
+#include "framework.h"
+#include "EchoServer.h"
+#include "EchoServerDlg.h"
+
+#ifdef _DEBUG
+#define new DEBUG_NEW
+#endif
+
+
+// CEchoServerApp
+
+BEGIN_MESSAGE_MAP(CEchoServerApp, CWinApp)
+ ON_COMMAND(ID_HELP, &CWinApp::OnHelp)
+END_MESSAGE_MAP()
+
+
+// CEchoServerApp 构造
+
+CEchoServerApp::CEchoServerApp()
+{
+ // 支持重新启动管理器
+ m_dwRestartManagerSupportFlags = AFX_RESTART_MANAGER_SUPPORT_RESTART;
+
+ // TODO: 在此处添加构造代码,
+ // 将所有重要的初始化放置在 InitInstance 中
+}
+
+
+// 唯一的 CEchoServerApp 对象
+
+CEchoServerApp theApp;
+
+
+// CEchoServerApp 初始化
+
+BOOL CEchoServerApp::InitInstance()
+{
+ // 如果一个运行在 Windows XP 上的应用程序清单指定要
+ // 使用 ComCtl32.dll 版本 6 或更高版本来启用可视化方式,
+ //则需要 InitCommonControlsEx()。 否则,将无法创建窗口。
+ INITCOMMONCONTROLSEX InitCtrls;
+ InitCtrls.dwSize = sizeof(InitCtrls);
+ // 将它设置为包括所有要在应用程序中使用的
+ // 公共控件类。
+ InitCtrls.dwICC = ICC_WIN95_CLASSES;
+ InitCommonControlsEx(&InitCtrls);
+
+ CWinApp::InitInstance();
+
+ if (!AfxSocketInit())
+ {
+ AfxMessageBox(IDP_SOCKETS_INIT_FAILED);
+ return FALSE;
+ }
+
+
+ AfxEnableControlContainer();
+
+ // 创建 shell 管理器,以防对话框包含
+ // 任何 shell 树视图控件或 shell 列表视图控件。
+ CShellManager *pShellManager = new CShellManager;
+
+ // 激活“Windows Native”视觉管理器,以便在 MFC 控件中启用主题
+ CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerWindows));
+
+ // 标准初始化
+ // 如果未使用这些功能并希望减小
+ // 最终可执行文件的大小,则应移除下列
+ // 不需要的特定初始化例程
+ // 更改用于存储设置的注册表项
+ // TODO: 应适当修改该字符串,
+ // 例如修改为公司或组织名
+ SetRegistryKey(_T("应用程序向导生成的本地应用程序"));
+
+ CEchoServerDlg dlg;
+ m_pMainWnd = &dlg;
+ INT_PTR nResponse = dlg.DoModal();
+ if (nResponse == IDOK)
+ {
+ // TODO: 在此放置处理何时用
+ // “确定”来关闭对话框的代码
+ }
+ else if (nResponse == IDCANCEL)
+ {
+ // TODO: 在此放置处理何时用
+ // “取消”来关闭对话框的代码
+ }
+ else if (nResponse == -1)
+ {
+ TRACE(traceAppMsg, 0, "警告: 对话框创建失败,应用程序将意外终止。\n");
+ TRACE(traceAppMsg, 0, "警告: 如果您在对话框上使用 MFC 控件,则无法 #define _AFX_NO_MFC_CONTROLS_IN_DIALOGS。\n");
+ }
+
+ // 删除上面创建的 shell 管理器。
+ if (pShellManager != nullptr)
+ {
+ delete pShellManager;
+ }
+
+#if !defined(_AFXDLL) && !defined(_AFX_NO_MFC_CONTROLS_IN_DIALOGS)
+ ControlBarCleanUp();
+#endif
+
+ // 由于对话框已关闭,所以将返回 FALSE 以便退出应用程序,
+ // 而不是启动应用程序的消息泵。
+ return FALSE;
+}
+
diff --git a/lib_fiber/samples-gui/EchoServer/EchoServer.h b/lib_fiber/samples-gui/EchoServer/EchoServer.h
new file mode 100644
index 000000000..721ec6123
--- /dev/null
+++ b/lib_fiber/samples-gui/EchoServer/EchoServer.h
@@ -0,0 +1,32 @@
+
+// EchoServer.h: PROJECT_NAME 应用程序的主头文件
+//
+
+#pragma once
+
+#ifndef __AFXWIN_H__
+ #error "在包含此文件之前包含 'pch.h' 以生成 PCH"
+#endif
+
+#include "resource.h" // 主符号
+
+
+// CEchoServerApp:
+// 有关此类的实现,请参阅 EchoServer.cpp
+//
+
+class CEchoServerApp : public CWinApp
+{
+public:
+ CEchoServerApp();
+
+// 重写
+public:
+ virtual BOOL InitInstance();
+
+// 实现
+
+ DECLARE_MESSAGE_MAP()
+};
+
+extern CEchoServerApp theApp;
diff --git a/lib_fiber/samples-gui/EchoServer/EchoServer.rc b/lib_fiber/samples-gui/EchoServer/EchoServer.rc
new file mode 100644
index 000000000..f80269de3
Binary files /dev/null and b/lib_fiber/samples-gui/EchoServer/EchoServer.rc differ
diff --git a/lib_fiber/samples-gui/EchoServer/EchoServer.vcxproj b/lib_fiber/samples-gui/EchoServer/EchoServer.vcxproj
new file mode 100644
index 000000000..a337e4dd1
--- /dev/null
+++ b/lib_fiber/samples-gui/EchoServer/EchoServer.vcxproj
@@ -0,0 +1,225 @@
+
+
+
+
+ Debug
+ Win32
+
+
+ Release
+ Win32
+
+
+ Debug
+ x64
+
+
+ Release
+ x64
+
+
+
+ 16.0
+ {30A882E6-CF13-494F-9132-CE15E040B9DE}
+ MFCProj
+ EchoServer
+ 10.0
+
+
+
+ Application
+ true
+ v142
+ MultiByte
+ Dynamic
+
+
+ Application
+ false
+ v142
+ true
+ MultiByte
+ Dynamic
+
+
+ Application
+ true
+ v142
+ Unicode
+ Dynamic
+
+
+ Application
+ false
+ v142
+ true
+ Unicode
+ Dynamic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ true
+
+
+ true
+
+
+ false
+
+
+ false
+
+
+
+ Use
+ Level3
+ true
+ WIN32;_WINDOWS;_DEBUG;%(PreprocessorDefinitions)
+ pch.h
+ ..\..\..\lib_fiber\cpp\include
+
+
+ Windows
+ $(SolutionDir)$(Configuration)\
+ libfiber.lib;libfiber_cpp.lib;lib_acl.lib;lib_protocol.lib;lib_acl_cpp.lib
+
+
+ false
+ true
+ _DEBUG;%(PreprocessorDefinitions)
+
+
+ 0x0804
+ _DEBUG;%(PreprocessorDefinitions)
+ $(IntDir);%(AdditionalIncludeDirectories)
+
+
+
+
+ Use
+ Level3
+ true
+ _WINDOWS;_DEBUG;%(PreprocessorDefinitions)
+ pch.h
+
+
+ Windows
+
+
+ false
+ true
+ _DEBUG;%(PreprocessorDefinitions)
+
+
+ 0x0804
+ _DEBUG;%(PreprocessorDefinitions)
+ $(IntDir);%(AdditionalIncludeDirectories)
+
+
+
+
+ Use
+ Level3
+ true
+ true
+ true
+ WIN32;_WINDOWS;NDEBUG;%(PreprocessorDefinitions)
+ pch.h
+ ..\..\..\lib_fiber\cpp\include
+
+
+ Windows
+ true
+ true
+ $(SolutionDir)$(Configuration)\
+ libfiber.lib;libfiber_cpp.lib;lib_acl.lib;lib_protocol.lib;lib_acl_cpp.lib
+
+
+ false
+ true
+ NDEBUG;%(PreprocessorDefinitions)
+
+
+ 0x0804
+ NDEBUG;%(PreprocessorDefinitions)
+ $(IntDir);%(AdditionalIncludeDirectories)
+
+
+
+
+ Use
+ Level3
+ true
+ true
+ true
+ _WINDOWS;NDEBUG;%(PreprocessorDefinitions)
+ pch.h
+
+
+ Windows
+ true
+ true
+
+
+ false
+ true
+ NDEBUG;%(PreprocessorDefinitions)
+
+
+ 0x0804
+ NDEBUG;%(PreprocessorDefinitions)
+ $(IntDir);%(AdditionalIncludeDirectories)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Create
+ Create
+ Create
+ Create
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/lib_fiber/samples-gui/EchoServer/EchoServer.vcxproj.filters b/lib_fiber/samples-gui/EchoServer/EchoServer.vcxproj.filters
new file mode 100644
index 000000000..dc23e20d2
--- /dev/null
+++ b/lib_fiber/samples-gui/EchoServer/EchoServer.vcxproj.filters
@@ -0,0 +1,75 @@
+
+
+
+
+ {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
+ cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx
+
+
+ {93995380-89BD-4b04-88EB-625FBE52EBFB}
+ h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd
+
+
+ {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
+ rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
+
+
+
+
+ 头文件
+
+
+ 头文件
+
+
+ 头文件
+
+
+ 头文件
+
+
+ 头文件
+
+
+ 头文件
+
+
+ 头文件
+
+
+ 头文件
+
+
+
+
+ 源文件
+
+
+ 源文件
+
+
+ 源文件
+
+
+ 源文件
+
+
+ 源文件
+
+
+
+
+ 资源文件
+
+
+
+
+ 资源文件
+
+
+
+
+ 资源文件
+
+
+
\ No newline at end of file
diff --git a/lib_fiber/samples-gui/EchoServer/EchoServerDlg.cpp b/lib_fiber/samples-gui/EchoServer/EchoServerDlg.cpp
new file mode 100644
index 000000000..0e48053ee
--- /dev/null
+++ b/lib_fiber/samples-gui/EchoServer/EchoServerDlg.cpp
@@ -0,0 +1,252 @@
+
+// EchoServerDlg.cpp: 实现文件
+//
+
+#include "pch.h"
+#include "framework.h"
+#include "EchoServer.h"
+#include "EchoServerDlg.h"
+#include "afxdialogex.h"
+
+#include "FiberServer.h"
+
+#ifdef _DEBUG
+#define new DEBUG_NEW
+#endif
+
+
+// 用于应用程序“关于”菜单项的 CAboutDlg 对话框
+
+class CAboutDlg : public CDialogEx
+{
+public:
+ CAboutDlg();
+
+// 对话框数据
+#ifdef AFX_DESIGN_TIME
+ enum { IDD = IDD_ABOUTBOX };
+#endif
+
+ protected:
+ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持
+
+// 实现
+protected:
+ DECLARE_MESSAGE_MAP()
+};
+
+CAboutDlg::CAboutDlg() : CDialogEx(IDD_ABOUTBOX)
+{
+}
+
+void CAboutDlg::DoDataExchange(CDataExchange* pDX)
+{
+ CDialogEx::DoDataExchange(pDX);
+}
+
+BEGIN_MESSAGE_MAP(CAboutDlg, CDialogEx)
+END_MESSAGE_MAP()
+
+
+// CEchoServerDlg 对话框
+
+CEchoServerDlg::CEchoServerDlg(CWnd* pParent /*=nullptr*/)
+: CDialogEx(IDD_ECHOSERVER_DIALOG, pParent)
+, m_port(8088)
+, m_listenFiber(NULL)
+{
+ m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
+}
+
+void CEchoServerDlg::DoDataExchange(CDataExchange* pDX)
+{
+ CDialogEx::DoDataExchange(pDX);
+ DDX_Text(pDX, IDC_PORT, m_port);
+ DDX_Control(pDX, IDC_IPADDR, m_listenAddr);
+}
+
+BEGIN_MESSAGE_MAP(CEchoServerDlg, CDialogEx)
+ ON_WM_SYSCOMMAND()
+ ON_WM_PAINT()
+ ON_WM_QUERYDRAGICON()
+ ON_BN_CLICKED(IDC_LISTEN, &CEchoServerDlg::OnBnClickedListen)
+ ON_BN_CLICKED(IDC_STOP_LISTEN, &CEchoServerDlg::OnBnClickedStopListen)
+ON_BN_CLICKED(IDOK, &CEchoServerDlg::OnBnClickedOk)
+ON_BN_CLICKED(IDCANCEL, &CEchoServerDlg::OnBnClickedCancel)
+END_MESSAGE_MAP()
+
+// CEchoServerDlg 消息处理程序
+
+BOOL CEchoServerDlg::OnInitDialog()
+{
+ CDialogEx::OnInitDialog();
+
+ // 将“关于...”菜单项添加到系统菜单中。
+
+ // IDM_ABOUTBOX 必须在系统命令范围内。
+ ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
+ ASSERT(IDM_ABOUTBOX < 0xF000);
+
+ CMenu* pSysMenu = GetSystemMenu(FALSE);
+ if (pSysMenu != nullptr) {
+ BOOL bNameValid;
+ CString strAboutMenu;
+ bNameValid = strAboutMenu.LoadString(IDS_ABOUTBOX);
+ ASSERT(bNameValid);
+ if (!strAboutMenu.IsEmpty()) {
+ pSysMenu->AppendMenu(MF_SEPARATOR);
+ pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
+ }
+ }
+
+ // 设置此对话框的图标。 当应用程序主窗口不是对话框时,框架将自动
+ // 执行此操作
+ SetIcon(m_hIcon, TRUE); // 设置大图标
+ SetIcon(m_hIcon, FALSE); // 设置小图标
+
+ // TODO: 在此添加额外的初始化代码
+
+ BYTE ip[4];
+ ip[0] = 0;
+ ip[1] = 0;
+ ip[2] = 0;
+ ip[3] = 0;
+ m_listenAddr.SetAddress(ip[0], ip[1], ip[2], ip[3]);
+
+ GetDlgItem(IDC_STOP_LISTEN)->EnableWindow(FALSE);
+ InitFiber();
+
+ return TRUE; // 除非将焦点设置到控件,否则返回 TRUE
+}
+
+void CEchoServerDlg::OnSysCommand(UINT nID, LPARAM lParam)
+{
+ if ((nID & 0xFFF0) == IDM_ABOUTBOX) {
+ CAboutDlg dlgAbout;
+ dlgAbout.DoModal();
+ } else {
+ CDialogEx::OnSysCommand(nID, lParam);
+ }
+}
+
+// 如果向对话框添加最小化按钮,则需要下面的代码
+// 来绘制该图标。 对于使用文档/视图模型的 MFC 应用程序,
+// 这将由框架自动完成。
+
+void CEchoServerDlg::OnPaint()
+{
+ if (IsIconic()) {
+ CPaintDC dc(this); // 用于绘制的设备上下文
+
+ SendMessage(WM_ICONERASEBKGND, reinterpret_cast(dc.GetSafeHdc()), 0);
+
+ // 使图标在工作区矩形中居中
+ int cxIcon = GetSystemMetrics(SM_CXICON);
+ int cyIcon = GetSystemMetrics(SM_CYICON);
+ CRect rect;
+ GetClientRect(&rect);
+ int x = (rect.Width() - cxIcon + 1) / 2;
+ int y = (rect.Height() - cyIcon + 1) / 2;
+
+ // 绘制图标
+ dc.DrawIcon(x, y, m_hIcon);
+ } else {
+ CDialogEx::OnPaint();
+ }
+}
+
+//当用户拖动最小化窗口时系统调用此函数取得光标
+//显示。
+HCURSOR CEchoServerDlg::OnQueryDragIcon()
+{
+ return static_cast(m_hIcon);
+}
+
+void CEchoServerDlg::InitFiber()
+{
+ // 设置协程调度的事件引擎,同时将协程调度设为自动启动模式,不能在进程初始化时启动
+ // 协程调试器,必须在界面消息引擎正常运行后才启动协程调度器!
+ acl::fiber::init(acl::FIBER_EVENT_T_WMSG, true);
+ acl::fiber::winapi_hook();
+}
+
+void CEchoServerDlg::StopFiber()
+{
+ // 停止协程调度过程
+ acl::fiber::schedule_stop();
+}
+
+void CEchoServerDlg::OnBnClickedListen()
+{
+ // TODO: 在此添加控件通知处理程序代码
+ UpdateData(TRUE);
+
+ BYTE ip[4];
+ m_listenAddr.GetAddress(ip[0], ip[1], ip[2], ip[3]);
+ CString ipAddr;
+ ipAddr.Format(_T("%d.%d.%d.%d"), ip[0], ip[1], ip[2], ip[3]);
+
+ SOCKET sock = socket(AF_INET, SOCK_STREAM, 0);
+ if (sock == INVALID_SOCKET) {
+ MessageBox("can't create socket!");
+ return;
+ }
+
+ struct sockaddr_in in;
+ in.sin_family = AF_INET;
+ in.sin_port = htons(m_port);
+ if (inet_pton(AF_INET, ipAddr.GetString(), &in.sin_addr) == -1) {
+ CString buf;
+ buf.Format("inet_pton error, addr=%s", ipAddr.GetString());
+ MessageBox(buf);
+ closesocket(sock);
+ return;
+ }
+
+ if (bind(sock, (const sockaddr*)&in, sizeof(in)) == -1) {
+ CString buf;
+ buf.Format("bind %s:%d error", ipAddr.GetString(), m_port);
+ MessageBox(buf);
+ closesocket(sock);
+ return;
+ }
+
+ if (listen(sock, 128) == -1) {
+ CString buf;
+ buf.Format("listen %s:%d error", ipAddr.GetString(), m_port);
+ MessageBox(buf);
+ closesocket(sock);
+ return;
+ }
+
+ GetDlgItem(IDC_LISTEN)->EnableWindow(FALSE);
+ GetDlgItem(IDC_STOP_LISTEN)->EnableWindow(TRUE);
+
+ m_listenFiber = new CFiberServer(sock);
+ m_listenFiber->start();
+}
+
+void CEchoServerDlg::OnBnClickedStopListen()
+{
+ if (m_listenFiber) {
+ acl::fiber* fb = m_listenFiber;
+ m_listenFiber = NULL;
+ fb->kill();
+ GetDlgItem(IDC_LISTEN)->EnableWindow(TRUE);
+ GetDlgItem(IDC_STOP_LISTEN)->EnableWindow(FALSE);
+ }
+}
+
+void CEchoServerDlg::OnBnClickedOk()
+{
+ // TODO: 在此添加控件通知处理程序代码
+ CDialogEx::OnOK();
+ StopFiber();
+}
+
+void CEchoServerDlg::OnBnClickedCancel()
+{
+ // TODO: 在此添加控件通知处理程序代码
+ CDialogEx::OnCancel();
+ StopFiber();
+}
diff --git a/lib_fiber/samples-gui/EchoServer/EchoServerDlg.h b/lib_fiber/samples-gui/EchoServer/EchoServerDlg.h
new file mode 100644
index 000000000..e87877467
--- /dev/null
+++ b/lib_fiber/samples-gui/EchoServer/EchoServerDlg.h
@@ -0,0 +1,48 @@
+
+// EchoServerDlg.h: 头文件
+//
+
+#pragma once
+
+
+// CEchoServerDlg 对话框
+class CEchoServerDlg : public CDialogEx
+{
+// 构造
+public:
+ CEchoServerDlg(CWnd* pParent = nullptr); // 标准构造函数
+
+// 对话框数据
+#ifdef AFX_DESIGN_TIME
+ enum { IDD = IDD_ECHOSERVER_DIALOG };
+#endif
+
+ protected:
+ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持
+
+
+// 实现
+protected:
+ HICON m_hIcon;
+
+ // 生成的消息映射函数
+ virtual BOOL OnInitDialog();
+ afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
+ afx_msg void OnPaint();
+ afx_msg HCURSOR OnQueryDragIcon();
+ DECLARE_MESSAGE_MAP()
+
+private:
+ UINT m_port;
+ CIPAddressCtrl m_listenAddr;
+ acl::fiber* m_listenFiber;
+
+ void InitFiber();
+ void StopFiber();
+
+public:
+ afx_msg void OnBnClickedListen();
+ afx_msg void OnBnClickedStopListen();
+afx_msg void OnBnClickedOk();
+afx_msg void OnBnClickedCancel();
+};
diff --git a/lib_fiber/samples-gui/EchoServer/FiberClient.cpp b/lib_fiber/samples-gui/EchoServer/FiberClient.cpp
new file mode 100644
index 000000000..e05cf7526
--- /dev/null
+++ b/lib_fiber/samples-gui/EchoServer/FiberClient.cpp
@@ -0,0 +1,29 @@
+#include "pch.h"
+#include "FiberClient.h"
+
+CFiberClient::CFiberClient(SOCKET s)
+: m_sock(s)
+{
+}
+
+CFiberClient::~CFiberClient(void)
+{
+ closesocket(m_sock);
+}
+
+void CFiberClient::run(void)
+{
+ char buf[8192];
+ while (true) {
+ int ret = recv(m_sock, buf, sizeof(buf), 0);
+ if (ret <= 0) {
+ break;
+ }
+
+ if (send(m_sock, buf, ret, 0) == -1) {
+ break;
+ }
+ }
+
+ delete this;
+}
diff --git a/lib_fiber/samples-gui/EchoServer/FiberClient.h b/lib_fiber/samples-gui/EchoServer/FiberClient.h
new file mode 100644
index 000000000..f8b649a93
--- /dev/null
+++ b/lib_fiber/samples-gui/EchoServer/FiberClient.h
@@ -0,0 +1,16 @@
+#pragma once
+class CFiberClient : public acl::fiber
+{
+public:
+ CFiberClient(SOCKET sock);
+
+private:
+ ~CFiberClient(void);
+
+protected:
+ void run(void);
+
+private:
+ SOCKET m_sock;
+};
+
diff --git a/lib_fiber/samples-gui/EchoServer/FiberServer.cpp b/lib_fiber/samples-gui/EchoServer/FiberServer.cpp
new file mode 100644
index 000000000..5c43b4a42
--- /dev/null
+++ b/lib_fiber/samples-gui/EchoServer/FiberServer.cpp
@@ -0,0 +1,28 @@
+#include "pch.h"
+#include "FiberClient.h"
+#include "FiberServer.h"
+
+CFiberServer::CFiberServer(SOCKET sock)
+ : m_sock(sock)
+{
+}
+
+CFiberServer::~CFiberServer(void)
+{
+ closesocket(m_sock);
+}
+
+void CFiberServer::run(void)
+{
+ while (true) {
+ SOCKET s = accept(m_sock, NULL, NULL);
+ if (s == INVALID_SOCKET) {
+ break;
+ }
+
+ acl::fiber* fb = new CFiberClient(s);
+ fb->start();
+ }
+
+ delete this;
+}
diff --git a/lib_fiber/samples-gui/EchoServer/FiberServer.h b/lib_fiber/samples-gui/EchoServer/FiberServer.h
new file mode 100644
index 000000000..89e81bc25
--- /dev/null
+++ b/lib_fiber/samples-gui/EchoServer/FiberServer.h
@@ -0,0 +1,18 @@
+#pragma once
+
+class CFiberServer : public acl::fiber
+{
+public:
+ CFiberServer(SOCKET sock);
+
+private:
+ ~CFiberServer(void);
+
+protected:
+ // @override
+ void run(void);
+
+private:
+ SOCKET m_sock;
+};
+
diff --git a/lib_fiber/samples-gui/EchoServer/framework.h b/lib_fiber/samples-gui/EchoServer/framework.h
new file mode 100644
index 000000000..3729c995a
--- /dev/null
+++ b/lib_fiber/samples-gui/EchoServer/framework.h
@@ -0,0 +1,50 @@
+#pragma once
+
+#ifndef VC_EXTRALEAN
+#define VC_EXTRALEAN // 从 Windows 头中排除极少使用的资料
+#endif
+
+#include "targetver.h"
+
+#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // 某些 CString 构造函数将是显式的
+
+// 关闭 MFC 的一些常见且经常可放心忽略的隐藏警告消息
+#define _AFX_ALL_WARNINGS
+
+#include // MFC 核心组件和标准组件
+#include // MFC 扩展
+
+
+#include // MFC 自动化类
+
+
+
+#ifndef _AFX_NO_OLE_SUPPORT
+#include // MFC 对 Internet Explorer 4 公共控件的支持
+#endif
+#ifndef _AFX_NO_AFXCMN_SUPPORT
+#include // MFC 对 Windows 公共控件的支持
+#endif // _AFX_NO_AFXCMN_SUPPORT
+
+#include // MFC 支持功能区和控制条
+
+
+#include // MFC 套接字扩展
+
+
+
+
+
+
+
+#ifdef _UNICODE
+#if defined _M_IX86
+#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"")
+#elif defined _M_X64
+#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"")
+#else
+#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
+#endif
+#endif
+
+
diff --git a/lib_fiber/samples-gui/EchoServer/pch.cpp b/lib_fiber/samples-gui/EchoServer/pch.cpp
new file mode 100644
index 000000000..b6fb8f4ab
--- /dev/null
+++ b/lib_fiber/samples-gui/EchoServer/pch.cpp
@@ -0,0 +1,5 @@
+// pch.cpp: 与预编译标头对应的源文件
+
+#include "pch.h"
+
+// 当使用预编译的头时,需要使用此源文件,编译才能成功。
diff --git a/lib_fiber/samples-gui/EchoServer/pch.h b/lib_fiber/samples-gui/EchoServer/pch.h
new file mode 100644
index 000000000..e18ac8006
--- /dev/null
+++ b/lib_fiber/samples-gui/EchoServer/pch.h
@@ -0,0 +1,14 @@
+// pch.h: 这是预编译标头文件。
+// 下方列出的文件仅编译一次,提高了将来生成的生成性能。
+// 这还将影响 IntelliSense 性能,包括代码完成和许多代码浏览功能。
+// 但是,如果此处列出的文件中的任何一个在生成之间有更新,它们全部都将被重新编译。
+// 请勿在此处添加要频繁更新的文件,这将使得性能优势无效。
+
+#ifndef PCH_H
+#define PCH_H
+
+// 添加要在此处预编译的标头
+#include "framework.h"
+#include "fiber/libfiber.hpp"
+
+#endif //PCH_H
diff --git a/lib_fiber/samples-gui/EchoServer/res/EchoServer.ico b/lib_fiber/samples-gui/EchoServer/res/EchoServer.ico
new file mode 100644
index 000000000..d56fbcdfd
Binary files /dev/null and b/lib_fiber/samples-gui/EchoServer/res/EchoServer.ico differ
diff --git a/lib_fiber/samples-gui/EchoServer/res/EchoServer.rc2 b/lib_fiber/samples-gui/EchoServer/res/EchoServer.rc2
new file mode 100644
index 000000000..4d08fff8f
Binary files /dev/null and b/lib_fiber/samples-gui/EchoServer/res/EchoServer.rc2 differ
diff --git a/lib_fiber/samples-gui/EchoServer/resource.h b/lib_fiber/samples-gui/EchoServer/resource.h
new file mode 100644
index 000000000..7b4648240
--- /dev/null
+++ b/lib_fiber/samples-gui/EchoServer/resource.h
@@ -0,0 +1,25 @@
+//{{NO_DEPENDENCIES}}
+// Microsoft Visual C++ 生成的包含文件。
+// 供 EchoServer.rc 使用
+//
+#define IDM_ABOUTBOX 0x0010
+#define IDD_ABOUTBOX 100
+#define IDS_ABOUTBOX 101
+#define IDD_ECHOSERVER_DIALOG 102
+#define IDP_SOCKETS_INIT_FAILED 103
+#define IDR_MAINFRAME 128
+#define IDC_LISTEN 1000
+#define IDC_IPADDR 1001
+#define IDC_PORT 1002
+#define IDC_STOP_LISTEN 1003
+
+// Next default values for new objects
+//
+#ifdef APSTUDIO_INVOKED
+#ifndef APSTUDIO_READONLY_SYMBOLS
+#define _APS_NEXT_RESOURCE_VALUE 130
+#define _APS_NEXT_COMMAND_VALUE 32771
+#define _APS_NEXT_CONTROL_VALUE 1004
+#define _APS_NEXT_SYMED_VALUE 101
+#endif
+#endif
diff --git a/lib_fiber/samples-gui/EchoServer/targetver.h b/lib_fiber/samples-gui/EchoServer/targetver.h
new file mode 100644
index 000000000..79934a35b
--- /dev/null
+++ b/lib_fiber/samples-gui/EchoServer/targetver.h
@@ -0,0 +1,8 @@
+#pragma once
+
+// 包括 SDKDDKVer.h 将定义可用的最高版本的 Windows 平台。
+
+//如果要为以前的 Windows 平台生成应用程序,请包括 WinSDKVer.h,并
+// 将 _WIN32_WINNT 宏设置为要支持的平台,然后再包括 SDKDDKVer.h。
+
+#include
diff --git a/lib_fiber/samples-gui/HttpGet/HttpClient.cpp b/lib_fiber/samples-gui/HttpGet/HttpClient.cpp
new file mode 100644
index 000000000..c5a743cf7
--- /dev/null
+++ b/lib_fiber/samples-gui/HttpGet/HttpClient.cpp
@@ -0,0 +1,141 @@
+#include "pch.h"
+#include "HttpGetDlg.h"
+#include "HttpClient.h"
+
+CHttpClient::CHttpClient(CHttpGetDlg& hWin, const CString& url)
+: m_hWin(&hWin)
+, m_box(NULL)
+, m_url(url)
+{
+}
+
+CHttpClient::CHttpClient(acl::fiber_tbox& box, const CString& url)
+: m_hWin(NULL)
+, m_box(&box)
+, m_url(url)
+{
+}
+
+CHttpClient::~CHttpClient() {}
+
+void CHttpClient::run()
+{
+ acl::http_url hu;
+ if (!hu.parse(m_url.GetString())) {
+ SetError("Invalid url=%s", m_url.GetString());
+ SetEnd();
+ return;
+ }
+
+ const char* domain = hu.get_domain();
+ unsigned short port = hu.get_port();
+ CString addr;
+ addr.Format("%s|%d", domain, port);
+ acl::http_request request(addr.GetString());
+
+ CString url;
+ url.Format("%s", hu.get_url_path());
+ const char* params = hu.get_url_params();
+ if (*params != 0) {
+ url.AppendFormat("?%s", params);
+ }
+
+ acl::http_header& header = request.request_header();
+ header.set_url(url.GetString()).accept_gzip(true).set_host(domain);
+
+ acl::string head;
+ header.build_request(head);
+ SetRequestHead(head.c_str());
+
+ if (!request.request(NULL, 0)) {
+ SetError("Send request to %s error: %s",
+ addr.GetString(), acl::last_serror());
+ SetEnd();
+ return;
+ }
+
+ acl::http_client* client = request.get_client();
+ head.clear();
+ client->sprint_header(head);
+ SetResponseHead(head);
+
+ long long length = request.body_length();
+ SetBodyTotalLength(length);
+
+ length = 0;
+ char buf[8192];
+ while (true) {
+ int ret = request.read_body(buf, sizeof(buf));
+ if (ret <= 0) {
+ break;
+ }
+
+ length += ret;
+ SetBodyLength(length);
+ }
+
+ SetBodyLength(length);
+ SetEnd();
+}
+
+void CHttpClient::SetError(const char* fmt, ...)
+{
+ va_list ap;
+ va_start(ap, fmt);
+ CString buf;
+ buf.FormatV(fmt, ap);
+ va_end(ap);
+
+ if (m_box) {
+ CHttpMsg* msg = new CHttpMsg(buf.GetString(), HTTP_MSG_ERR);
+ m_box->push(msg);
+ } else if (m_hWin) {
+ m_hWin->SetError("%s", buf.GetString());
+ }
+}
+
+void CHttpClient::SetRequestHead(const char* data)
+{
+ if (m_box) {
+ CHttpMsg* msg = new CHttpMsg(data, HTTP_MSG_REQ);
+ m_box->push(msg);
+ } else if (m_hWin) {
+ m_hWin->SetRequestHead(data);
+ }
+}
+
+void CHttpClient::SetResponseHead(const char* data)
+{
+ if (m_box) {
+ CHttpMsg* msg = new CHttpMsg(data, HTTP_MSG_RES);
+ m_box->push(msg);
+ } else if (m_hWin) {
+ m_hWin->SetResponseHead(data);
+ }
+}
+
+void CHttpClient::SetBodyTotalLength(long long length)
+{
+ if (m_box) {
+ CHttpMsg* msg = new CHttpMsg(length, HTTP_MSG_TOTAL_LENGTH);
+ m_box->push(msg);
+ } else if (m_hWin) {
+ m_hWin->SetBodyTotalLength(length);
+ }
+}
+
+void CHttpClient::SetBodyLength(long long length)
+{
+ if (m_box) {
+ CHttpMsg* msg = new CHttpMsg(length, HTTP_MSG_LENGTH);
+ m_box->push(msg);
+ } else if (m_hWin) {
+ m_hWin->SetBodyLength(length);
+ }
+}
+
+void CHttpClient::SetEnd() {
+ if (m_box) {
+ m_box->push(NULL);
+ }
+}
diff --git a/lib_fiber/samples-gui/HttpGet/HttpClient.h b/lib_fiber/samples-gui/HttpGet/HttpClient.h
new file mode 100644
index 000000000..069274ace
--- /dev/null
+++ b/lib_fiber/samples-gui/HttpGet/HttpClient.h
@@ -0,0 +1,46 @@
+#pragma once
+
+class CHttpGetDlg;
+
+enum {
+ HTTP_MSG_ERR,
+ HTTP_MSG_REQ,
+ HTTP_MSG_RES,
+ HTTP_MSG_TOTAL_LENGTH,
+ HTTP_MSG_LENGTH,
+};
+
+class CHttpMsg {
+public:
+ CHttpMsg(const char* s, int type) : m_buf(s), m_length(0), m_type(type) {}
+ CHttpMsg(long long len, int type) : m_length(len), m_type(type) {}
+ ~CHttpMsg(void) {}
+
+ CString m_buf;
+ long long m_length;
+ int m_type;
+};
+
+class CHttpClient
+{
+public:
+ CHttpClient(CHttpGetDlg& hWin, const CString& url);
+ CHttpClient(acl::fiber_tbox& mBox, const CString& url);
+ ~CHttpClient();
+
+ void run();
+
+private:
+ CHttpGetDlg* m_hWin;
+ acl::fiber_tbox* m_box;
+ CString m_url;
+
+private:
+ void SetError(const char* fmt, ...);
+ void SetRequestHead(const char* data);
+ void SetResponseHead(const char* data);
+ void SetBodyTotalLength(long long length);
+ void SetBodyLength(long long length);
+ void SetEnd();
+};
+
diff --git a/lib_fiber/samples-gui/HttpGet/HttpGet.cpp b/lib_fiber/samples-gui/HttpGet/HttpGet.cpp
new file mode 100644
index 000000000..9b006ddc7
--- /dev/null
+++ b/lib_fiber/samples-gui/HttpGet/HttpGet.cpp
@@ -0,0 +1,113 @@
+
+// HttpGet.cpp: 定义应用程序的类行为。
+//
+
+#include "pch.h"
+#include "framework.h"
+#include "HttpGet.h"
+#include "HttpGetDlg.h"
+
+#ifdef _DEBUG
+#define new DEBUG_NEW
+#endif
+
+
+// CHttpGetApp
+
+BEGIN_MESSAGE_MAP(CHttpGetApp, CWinApp)
+ ON_COMMAND(ID_HELP, &CWinApp::OnHelp)
+END_MESSAGE_MAP()
+
+
+// CHttpGetApp 构造
+
+CHttpGetApp::CHttpGetApp()
+{
+ // 支持重新启动管理器
+ m_dwRestartManagerSupportFlags = AFX_RESTART_MANAGER_SUPPORT_RESTART;
+
+ // TODO: 在此处添加构造代码,
+ // 将所有重要的初始化放置在 InitInstance 中
+}
+
+
+// 唯一的 CHttpGetApp 对象
+
+CHttpGetApp theApp;
+
+
+// CHttpGetApp 初始化
+
+BOOL CHttpGetApp::InitInstance()
+{
+ // 如果一个运行在 Windows XP 上的应用程序清单指定要
+ // 使用 ComCtl32.dll 版本 6 或更高版本来启用可视化方式,
+ //则需要 InitCommonControlsEx()。 否则,将无法创建窗口。
+ INITCOMMONCONTROLSEX InitCtrls;
+ InitCtrls.dwSize = sizeof(InitCtrls);
+ // 将它设置为包括所有要在应用程序中使用的
+ // 公共控件类。
+ InitCtrls.dwICC = ICC_WIN95_CLASSES;
+ InitCommonControlsEx(&InitCtrls);
+
+ CWinApp::InitInstance();
+
+ if (!AfxSocketInit())
+ {
+ AfxMessageBox(IDP_SOCKETS_INIT_FAILED);
+ return FALSE;
+ }
+
+
+ AfxEnableControlContainer();
+
+ // 创建 shell 管理器,以防对话框包含
+ // 任何 shell 树视图控件或 shell 列表视图控件。
+ CShellManager *pShellManager = new CShellManager;
+
+ // 激活“Windows Native”视觉管理器,以便在 MFC 控件中启用主题
+ CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerWindows));
+
+ // 标准初始化
+ // 如果未使用这些功能并希望减小
+ // 最终可执行文件的大小,则应移除下列
+ // 不需要的特定初始化例程
+ // 更改用于存储设置的注册表项
+ // TODO: 应适当修改该字符串,
+ // 例如修改为公司或组织名
+ SetRegistryKey(_T("应用程序向导生成的本地应用程序"));
+
+ CHttpGetDlg dlg;
+ m_pMainWnd = &dlg;
+ INT_PTR nResponse = dlg.DoModal();
+ if (nResponse == IDOK)
+ {
+ // TODO: 在此放置处理何时用
+ // “确定”来关闭对话框的代码
+ }
+ else if (nResponse == IDCANCEL)
+ {
+ // TODO: 在此放置处理何时用
+ // “取消”来关闭对话框的代码
+ }
+ else if (nResponse == -1)
+ {
+ TRACE(traceAppMsg, 0, "警告: 对话框创建失败,应用程序将意外终止。\n");
+ TRACE(traceAppMsg, 0, "警告: 如果您在对话框上使用 MFC 控件,则无法 #define _AFX_NO_MFC_CONTROLS_IN_DIALOGS。\n");
+ }
+
+ // 删除上面创建的 shell 管理器。
+ if (pShellManager != nullptr)
+ {
+ delete pShellManager;
+ }
+
+#if !defined(_AFXDLL) && !defined(_AFX_NO_MFC_CONTROLS_IN_DIALOGS)
+ ControlBarCleanUp();
+#endif
+
+ // 由于对话框已关闭,所以将返回 FALSE 以便退出应用程序,
+ // 而不是启动应用程序的消息泵。
+ return FALSE;
+}
+
diff --git a/lib_fiber/samples-gui/HttpGet/HttpGet.h b/lib_fiber/samples-gui/HttpGet/HttpGet.h
new file mode 100644
index 000000000..b5b6c9b3c
--- /dev/null
+++ b/lib_fiber/samples-gui/HttpGet/HttpGet.h
@@ -0,0 +1,32 @@
+
+// HttpGet.h: PROJECT_NAME 应用程序的主头文件
+//
+
+#pragma once
+
+#ifndef __AFXWIN_H__
+ #error "在包含此文件之前包含 'pch.h' 以生成 PCH"
+#endif
+
+#include "resource.h" // 主符号
+
+
+// CHttpGetApp:
+// 有关此类的实现,请参阅 HttpGet.cpp
+//
+
+class CHttpGetApp : public CWinApp
+{
+public:
+ CHttpGetApp();
+
+// 重写
+public:
+ virtual BOOL InitInstance();
+
+// 实现
+
+ DECLARE_MESSAGE_MAP()
+};
+
+extern CHttpGetApp theApp;
diff --git a/lib_fiber/samples-gui/HttpGet/HttpGet.rc b/lib_fiber/samples-gui/HttpGet/HttpGet.rc
new file mode 100644
index 000000000..e341a7330
Binary files /dev/null and b/lib_fiber/samples-gui/HttpGet/HttpGet.rc differ
diff --git a/lib_fiber/samples-gui/HttpGet/HttpGet.vcxproj b/lib_fiber/samples-gui/HttpGet/HttpGet.vcxproj
new file mode 100644
index 000000000..2680e206e
--- /dev/null
+++ b/lib_fiber/samples-gui/HttpGet/HttpGet.vcxproj
@@ -0,0 +1,223 @@
+
+
+
+
+ Debug
+ Win32
+
+
+ Release
+ Win32
+
+
+ Debug
+ x64
+
+
+ Release
+ x64
+
+
+
+ 16.0
+ {FE7E9F00-7F46-4072-8B29-A4E915259CDE}
+ MFCProj
+ HttpGet
+ 10.0
+
+
+
+ Application
+ true
+ v142
+ MultiByte
+ Dynamic
+
+
+ Application
+ false
+ v142
+ true
+ MultiByte
+ Dynamic
+
+
+ Application
+ true
+ v142
+ Unicode
+ Dynamic
+
+
+ Application
+ false
+ v142
+ true
+ Unicode
+ Dynamic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ true
+
+
+ true
+
+
+ false
+
+
+ false
+
+
+
+ Use
+ Level3
+ true
+ WIN32;_WINDOWS;_DEBUG;%(PreprocessorDefinitions)
+ pch.h
+ ..\..\..\lib_acl_cpp\include;..\..\..\lib_acl\include;..\..\..\lib_fiber\c\include;..\..\..\lib_fiber\cpp\include
+
+
+ Windows
+ $(SolutionDir)$(Configuration)\
+ libfiber.lib;libfiber_cpp.lib;lib_acl.lib;lib_protocol.lib;lib_acl_cpp.lib
+
+
+ false
+ true
+ _DEBUG;%(PreprocessorDefinitions)
+
+
+ 0x0804
+ _DEBUG;%(PreprocessorDefinitions)
+ $(IntDir);%(AdditionalIncludeDirectories)
+
+
+
+
+ Use
+ Level3
+ true
+ _WINDOWS;_DEBUG;%(PreprocessorDefinitions)
+ pch.h
+
+
+ Windows
+
+
+ false
+ true
+ _DEBUG;%(PreprocessorDefinitions)
+
+
+ 0x0804
+ _DEBUG;%(PreprocessorDefinitions)
+ $(IntDir);%(AdditionalIncludeDirectories)
+
+
+
+
+ Use
+ Level3
+ true
+ true
+ true
+ WIN32;_WINDOWS;NDEBUG;%(PreprocessorDefinitions)
+ pch.h
+ ..\..\..\lib_acl_cpp\include;..\..\..\lib_acl\include;..\..\..\lib_fiber\c\include;..\..\..\lib_fiber\cpp\include
+
+
+ Windows
+ true
+ true
+ $(SolutionDir)$(Configuration)\
+ libfiber.lib;libfiber_cpp.lib;lib_acl.lib;lib_protocol.lib;lib_acl_cpp.lib
+
+
+ false
+ true
+ NDEBUG;%(PreprocessorDefinitions)
+
+
+ 0x0804
+ NDEBUG;%(PreprocessorDefinitions)
+ $(IntDir);%(AdditionalIncludeDirectories)
+
+
+
+
+ Use
+ Level3
+ true
+ true
+ true
+ _WINDOWS;NDEBUG;%(PreprocessorDefinitions)
+ pch.h
+
+
+ Windows
+ true
+ true
+
+
+ false
+ true
+ NDEBUG;%(PreprocessorDefinitions)
+
+
+ 0x0804
+ NDEBUG;%(PreprocessorDefinitions)
+ $(IntDir);%(AdditionalIncludeDirectories)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Create
+ Create
+ Create
+ Create
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/lib_fiber/samples-gui/HttpGet/HttpGet.vcxproj.filters b/lib_fiber/samples-gui/HttpGet/HttpGet.vcxproj.filters
new file mode 100644
index 000000000..0eafd3697
--- /dev/null
+++ b/lib_fiber/samples-gui/HttpGet/HttpGet.vcxproj.filters
@@ -0,0 +1,69 @@
+
+
+
+
+ {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
+ cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx
+
+
+ {93995380-89BD-4b04-88EB-625FBE52EBFB}
+ h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd
+
+
+ {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
+ rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
+
+
+
+
+ 头文件
+
+
+ 头文件
+
+
+ 头文件
+
+
+ 头文件
+
+
+ 头文件
+
+
+ 头文件
+
+
+ 头文件
+
+
+
+
+ 源文件
+
+
+ 源文件
+
+
+ 源文件
+
+
+ 源文件
+
+
+
+
+ 资源文件
+
+
+
+
+ 资源文件
+
+
+
+
+ 资源文件
+
+
+
\ No newline at end of file
diff --git a/lib_fiber/samples-gui/HttpGet/HttpGetDlg.cpp b/lib_fiber/samples-gui/HttpGet/HttpGetDlg.cpp
new file mode 100644
index 000000000..ee23ae094
--- /dev/null
+++ b/lib_fiber/samples-gui/HttpGet/HttpGetDlg.cpp
@@ -0,0 +1,311 @@
+
+// HttpGetDlg.cpp: 实现文件
+//
+
+#include "pch.h"
+#include "framework.h"
+#include "HttpGet.h"
+#include "HttpGetDlg.h"
+#include "afxdialogex.h"
+
+#include "HttpClient.h"
+
+#ifdef _DEBUG
+#define new DEBUG_NEW
+#endif
+
+// 用于应用程序“关于”菜单项的 CAboutDlg 对话框
+
+class CAboutDlg : public CDialogEx
+{
+public:
+ CAboutDlg();
+
+// 对话框数据
+#ifdef AFX_DESIGN_TIME
+ enum { IDD = IDD_ABOUTBOX };
+#endif
+
+ protected:
+ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持
+
+// 实现
+protected:
+ DECLARE_MESSAGE_MAP()
+};
+
+CAboutDlg::CAboutDlg() : CDialogEx(IDD_ABOUTBOX)
+{
+}
+
+void CAboutDlg::DoDataExchange(CDataExchange* pDX)
+{
+ CDialogEx::DoDataExchange(pDX);
+}
+
+BEGIN_MESSAGE_MAP(CAboutDlg, CDialogEx)
+END_MESSAGE_MAP()
+
+// CHttpGetDlg 对话框
+
+CHttpGetDlg::CHttpGetDlg(CWnd* pParent /*=nullptr*/)
+: CDialogEx(IDD_HTTPGET_DIALOG, pParent)
+, m_url("http://www.baidu.com/")
+, m_length(-1)
+, m_lastPos(0)
+, m_downType(0)
+{
+ m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
+}
+
+void CHttpGetDlg::DoDataExchange(CDataExchange* pDX)
+{
+ CDialogEx::DoDataExchange(pDX);
+ DDX_Control(pDX, IDC_DOWN_PROGRESS, m_progress);
+ DDX_Text(pDX, IDC_URL, m_url);
+ DDX_Control(pDX, IDC_REQUEST_HEAD, m_request);
+ DDX_Control(pDX, IDC_RESPONSE, m_response);
+ DDX_Radio(pDX, IDC_RADIO_FIBER, m_downType);
+}
+
+BEGIN_MESSAGE_MAP(CHttpGetDlg, CDialogEx)
+ ON_WM_SYSCOMMAND()
+ ON_WM_PAINT()
+ ON_WM_QUERYDRAGICON()
+ ON_BN_CLICKED(IDOK, &CHttpGetDlg::OnBnClickedOk)
+ ON_BN_CLICKED(IDCANCEL, &CHttpGetDlg::OnBnClickedCancel)
+ ON_BN_CLICKED(IDC_START_GET, &CHttpGetDlg::OnBnClickedStartGet)
+ ON_BN_CLICKED(IDC_RESET, &CHttpGetDlg::OnBnClickedReset)
+ ON_BN_CLICKED(IDC_RADIO_FIBER, &CHttpGetDlg::OnBnClickedRadio)
+ ON_BN_CLICKED(IDC_RADIO_THREAD, &CHttpGetDlg::OnBnClickedRadio)
+END_MESSAGE_MAP()
+
+
+// CHttpGetDlg 消息处理程序
+
+BOOL CHttpGetDlg::OnInitDialog()
+{
+ CDialogEx::OnInitDialog();
+
+ // 将“关于...”菜单项添加到系统菜单中。
+
+ // IDM_ABOUTBOX 必须在系统命令范围内。
+ ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
+ ASSERT(IDM_ABOUTBOX < 0xF000);
+
+ CMenu* pSysMenu = GetSystemMenu(FALSE);
+ if (pSysMenu != nullptr) {
+ BOOL bNameValid;
+ CString strAboutMenu;
+ bNameValid = strAboutMenu.LoadString(IDS_ABOUTBOX);
+ ASSERT(bNameValid);
+ if (!strAboutMenu.IsEmpty()) {
+ pSysMenu->AppendMenu(MF_SEPARATOR);
+ pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
+ }
+ }
+
+ // 设置此对话框的图标。 当应用程序主窗口不是对话框时,框架将自动
+ // 执行此操作
+ SetIcon(m_hIcon, TRUE); // 设置大图标
+ SetIcon(m_hIcon, FALSE); // 设置小图标
+
+ // TODO: 在此添加额外的初始化代码
+ InitFiber();
+
+ m_progress.SetRange(0, 100);
+ m_progress.SetPos(0);
+
+ return TRUE; // 除非将焦点设置到控件,否则返回 TRUE
+}
+
+void CHttpGetDlg::OnSysCommand(UINT nID, LPARAM lParam)
+{
+ if ((nID & 0xFFF0) == IDM_ABOUTBOX) {
+ CAboutDlg dlgAbout;
+ dlgAbout.DoModal();
+ } else {
+ CDialogEx::OnSysCommand(nID, lParam);
+ }
+}
+
+// 如果向对话框添加最小化按钮,则需要下面的代码
+// 来绘制该图标。 对于使用文档/视图模型的 MFC 应用程序,
+// 这将由框架自动完成。
+
+void CHttpGetDlg::OnPaint()
+{
+ if (IsIconic()) {
+ CPaintDC dc(this); // 用于绘制的设备上下文
+
+ SendMessage(WM_ICONERASEBKGND, reinterpret_cast(dc.GetSafeHdc()), 0);
+
+ // 使图标在工作区矩形中居中
+ int cxIcon = GetSystemMetrics(SM_CXICON);
+ int cyIcon = GetSystemMetrics(SM_CYICON);
+ CRect rect;
+ GetClientRect(&rect);
+ int x = (rect.Width() - cxIcon + 1) / 2;
+ int y = (rect.Height() - cyIcon + 1) / 2;
+
+ // 绘制图标
+ dc.DrawIcon(x, y, m_hIcon);
+ } else {
+ CDialogEx::OnPaint();
+ }
+}
+
+//当用户拖动最小化窗口时系统调用此函数取得光标
+//显示。
+HCURSOR CHttpGetDlg::OnQueryDragIcon()
+{
+ return static_cast(m_hIcon);
+}
+
+void CHttpGetDlg::InitFiber()
+{
+ acl::acl_cpp_init();
+ // 设置协程调度的事件引擎,同时将协程调度设为自动启动模式,不能在进程初始化时启动
+ // 协程调试器,必须在界面消息引擎正常运行后才启动协程调度器!
+ acl::fiber::init(acl::FIBER_EVENT_T_WMSG, true);
+ acl::fiber::winapi_hook();
+}
+
+void CHttpGetDlg::OnBnClickedOk()
+{
+ // TODO: 在此添加控件通知处理程序代码
+ CDialogEx::OnOK();
+}
+
+void CHttpGetDlg::OnBnClickedCancel()
+{
+ // TODO: 在此添加控件通知处理程序代码
+ CDialogEx::OnCancel();
+}
+
+void CHttpGetDlg::OnBnClickedStartGet()
+{
+ // TODO: 在此添加控件通知处理程序代码
+ CString* url = new CString;
+ GetDlgItem(IDC_URL)->GetWindowText(*url);
+ if (url->IsEmpty()) {
+ MessageBox("Please input http url first!");
+ GetDlgItem(IDC_URL)->SetFocus();
+ delete url;
+ return;
+ }
+
+ m_progress.SetPos(0);
+ m_lastPos = 0;
+
+ if (m_downType == HTTP_DOWNLOAD_FIBER) {
+ go[=] {
+ CHttpClient client(*this, *url);
+ delete url;
+ client.run();
+ };
+ } else if (m_downType == HTTP_DOWNLOAD_THREAD) {
+ go[=] {
+ acl::fiber_tbox box;
+ std::thread thread([&] {
+ CHttpClient client(box, *url);
+ delete url;
+ client.run();
+ });
+
+ thread.detach();
+
+ while (true) {
+ CHttpMsg* msg = box.pop();
+ if (msg == NULL) {
+ break;
+ }
+ switch (msg->m_type) {
+ case HTTP_MSG_ERR:
+ SetError("%s", msg->m_buf.GetString());
+ break;
+ case HTTP_MSG_REQ:
+ SetRequestHead(msg->m_buf.GetString());
+ break;
+ case HTTP_MSG_RES:
+ SetResponseHead(msg->m_buf.GetString());
+ break;
+ case HTTP_MSG_TOTAL_LENGTH:
+ SetBodyTotalLength(msg->m_length);
+ break;
+ case HTTP_MSG_LENGTH:
+ SetBodyLength(msg->m_length);
+ break;
+ default:
+ break;
+ }
+ delete msg;
+ }
+ };
+ } else {
+ delete url;
+ }
+}
+
+void CHttpGetDlg::OnBnClickedReset()
+{
+ // TODO: 在此添加控件通知处理程序代码
+ m_progress.SetPos(0);
+ m_lastPos = 0;
+ GetDlgItem(IDC_REQUEST_HEAD)->SetWindowText("");
+ GetDlgItem(IDC_RESPONSE)->SetWindowTextA("");
+}
+
+void CHttpGetDlg::SetError(const char* fmt, ...)
+{
+ va_list ap;
+ va_start(ap, fmt);
+
+ CString msg;
+ msg.FormatV(fmt, ap);
+ va_end(ap);
+
+ MessageBox(msg);
+}
+
+void CHttpGetDlg::SetRequestHead(const char* str)
+{
+ m_request.SetWindowText(str);
+}
+
+void CHttpGetDlg::SetResponseHead(const char* str)
+{
+ m_response.SetWindowText(str);
+}
+
+void CHttpGetDlg::SetBodyTotalLength(long long length)
+{
+ m_length = length;
+}
+
+void CHttpGetDlg::SetBodyLength(long long length)
+{
+ if (m_length <= 0) {
+ return;
+ }
+
+ UINT n = (UINT) (100 * length / m_length);
+ if (n >= m_lastPos + 1) {
+ m_progress.SetPos(n);
+ m_lastPos = n;
+ }
+}
+
+void CHttpGetDlg::OnBnClickedRadio()
+{
+ // TODO: 在此添加控件通知处理程序代码
+ UpdateData(TRUE);
+ switch (m_downType) {
+ case HTTP_DOWNLOAD_FIBER:
+ break;
+ case HTTP_DOWNLOAD_THREAD:
+ break;
+ default:
+ break;
+ }
+}
diff --git a/lib_fiber/samples-gui/HttpGet/HttpGetDlg.h b/lib_fiber/samples-gui/HttpGet/HttpGetDlg.h
new file mode 100644
index 000000000..58803e067
--- /dev/null
+++ b/lib_fiber/samples-gui/HttpGet/HttpGetDlg.h
@@ -0,0 +1,66 @@
+
+// HttpGetDlg.h: 头文件
+//
+
+#pragma once
+
+enum {
+ HTTP_DOWNLOAD_FIBER = 0,
+ HTTP_DOWNLOAD_THREAD = 1,
+};
+
+// CHttpGetDlg 对话框
+class CHttpGetDlg : public CDialogEx
+{
+// 构造
+public:
+ CHttpGetDlg(CWnd* pParent = nullptr); // 标准构造函数
+
+// 对话框数据
+#ifdef AFX_DESIGN_TIME
+ enum { IDD = IDD_HTTPGET_DIALOG };
+#endif
+
+ protected:
+ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持
+
+
+// 实现
+protected:
+ HICON m_hIcon;
+
+ // 生成的消息映射函数
+ virtual BOOL OnInitDialog();
+ afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
+ afx_msg void OnPaint();
+ afx_msg HCURSOR OnQueryDragIcon();
+ DECLARE_MESSAGE_MAP()
+
+private:
+ void InitFiber();
+
+public:
+ afx_msg void OnBnClickedOk();
+ afx_msg void OnBnClickedCancel();
+ afx_msg void OnBnClickedStartGet();
+ afx_msg void OnBnClickedReset();
+ afx_msg void OnBnClickedRadio();
+
+private:
+ CProgressCtrl m_progress;
+ CString m_url;
+ int m_downType;
+ CEdit m_request;
+ CEdit m_response;
+
+ long long m_length;
+ UINT m_lastPos;
+
+public:
+ void SetError(const char* fmt, ...);
+
+ void SetRequestHead(const char* str);
+ void SetResponseHead(const char* str);
+ void SetBodyTotalLength(long long length);
+ void SetBodyLength(long long length);
+};
diff --git a/lib_fiber/samples-gui/HttpGet/framework.h b/lib_fiber/samples-gui/HttpGet/framework.h
new file mode 100644
index 000000000..3729c995a
--- /dev/null
+++ b/lib_fiber/samples-gui/HttpGet/framework.h
@@ -0,0 +1,50 @@
+#pragma once
+
+#ifndef VC_EXTRALEAN
+#define VC_EXTRALEAN // 从 Windows 头中排除极少使用的资料
+#endif
+
+#include "targetver.h"
+
+#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // 某些 CString 构造函数将是显式的
+
+// 关闭 MFC 的一些常见且经常可放心忽略的隐藏警告消息
+#define _AFX_ALL_WARNINGS
+
+#include // MFC 核心组件和标准组件
+#include // MFC 扩展
+
+
+#include // MFC 自动化类
+
+
+
+#ifndef _AFX_NO_OLE_SUPPORT
+#include // MFC 对 Internet Explorer 4 公共控件的支持
+#endif
+#ifndef _AFX_NO_AFXCMN_SUPPORT
+#include // MFC 对 Windows 公共控件的支持
+#endif // _AFX_NO_AFXCMN_SUPPORT
+
+#include // MFC 支持功能区和控制条
+
+
+#include // MFC 套接字扩展
+
+
+
+
+
+
+
+#ifdef _UNICODE
+#if defined _M_IX86
+#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"")
+#elif defined _M_X64
+#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"")
+#else
+#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
+#endif
+#endif
+
+
diff --git a/lib_fiber/samples-gui/HttpGet/pch.cpp b/lib_fiber/samples-gui/HttpGet/pch.cpp
new file mode 100644
index 000000000..b6fb8f4ab
--- /dev/null
+++ b/lib_fiber/samples-gui/HttpGet/pch.cpp
@@ -0,0 +1,5 @@
+// pch.cpp: 与预编译标头对应的源文件
+
+#include "pch.h"
+
+// 当使用预编译的头时,需要使用此源文件,编译才能成功。
diff --git a/lib_fiber/samples-gui/HttpGet/pch.h b/lib_fiber/samples-gui/HttpGet/pch.h
new file mode 100644
index 000000000..b86b8ffa5
--- /dev/null
+++ b/lib_fiber/samples-gui/HttpGet/pch.h
@@ -0,0 +1,17 @@
+// pch.h: 这是预编译标头文件。
+// 下方列出的文件仅编译一次,提高了将来生成的生成性能。
+// 这还将影响 IntelliSense 性能,包括代码完成和许多代码浏览功能。
+// 但是,如果此处列出的文件中的任何一个在生成之间有更新,它们全部都将被重新编译。
+// 请勿在此处添加要频繁更新的文件,这将使得性能优势无效。
+
+#ifndef PCH_H
+#define PCH_H
+
+// 添加要在此处预编译的标头
+#include "framework.h"
+
+#include "acl_cpp/lib_acl.hpp"
+#include "fiber/libfiber.hpp"
+#include "fiber/go_fiber.hpp"
+
+#endif //PCH_H
diff --git a/lib_fiber/samples-gui/HttpGet/res/HttpGet.ico b/lib_fiber/samples-gui/HttpGet/res/HttpGet.ico
new file mode 100644
index 000000000..d56fbcdfd
Binary files /dev/null and b/lib_fiber/samples-gui/HttpGet/res/HttpGet.ico differ
diff --git a/lib_fiber/samples-gui/HttpGet/res/HttpGet.rc2 b/lib_fiber/samples-gui/HttpGet/res/HttpGet.rc2
new file mode 100644
index 000000000..af37f50ff
Binary files /dev/null and b/lib_fiber/samples-gui/HttpGet/res/HttpGet.rc2 differ
diff --git a/lib_fiber/samples-gui/HttpGet/resource.h b/lib_fiber/samples-gui/HttpGet/resource.h
new file mode 100644
index 000000000..d8979689b
--- /dev/null
+++ b/lib_fiber/samples-gui/HttpGet/resource.h
@@ -0,0 +1,34 @@
+//{{NO_DEPENDENCIES}}
+// Microsoft Visual C++ 生成的包含文件。
+// 供 HttpGet.rc 使用
+//
+#define IDM_ABOUTBOX 0x0010
+#define IDD_ABOUTBOX 100
+#define IDS_ABOUTBOX 101
+#define IDD_HTTPGET_DIALOG 102
+#define IDP_SOCKETS_INIT_FAILED 103
+#define IDR_MAINFRAME 128
+#define IDC_START_GET 1000
+#define IDC_URL 1001
+#define IDC_STATIC_URL 1002
+#define IDC_REQ_HEAD 1003
+#define IDC_RES_HEAD 1004
+#define IDC_REQUEST_HEAD 1005
+#define IDC_RESPONSE 1006
+#define IDC_DOWN_PROGRESS 1007
+#define IDC_BUTTON2 1008
+#define IDC_RESET 1008
+#define IDC_RADIO_FIBER 1009
+#define IDC_RADIO2 1010
+#define IDC_RADIO_THREAD 1010
+
+// Next default values for new objects
+//
+#ifdef APSTUDIO_INVOKED
+#ifndef APSTUDIO_READONLY_SYMBOLS
+#define _APS_NEXT_RESOURCE_VALUE 130
+#define _APS_NEXT_COMMAND_VALUE 32771
+#define _APS_NEXT_CONTROL_VALUE 1011
+#define _APS_NEXT_SYMED_VALUE 101
+#endif
+#endif
diff --git a/lib_fiber/samples-gui/HttpGet/targetver.h b/lib_fiber/samples-gui/HttpGet/targetver.h
new file mode 100644
index 000000000..79934a35b
--- /dev/null
+++ b/lib_fiber/samples-gui/HttpGet/targetver.h
@@ -0,0 +1,8 @@
+#pragma once
+
+// 包括 SDKDDKVer.h 将定义可用的最高版本的 Windows 平台。
+
+//如果要为以前的 Windows 平台生成应用程序,请包括 WinSDKVer.h,并
+// 将 _WIN32_WINNT 宏设置为要支持的平台,然后再包括 SDKDDKVer.h。
+
+#include
diff --git a/lib_fiber/samples-gui/WinFiber/WinFiberDlg.cpp b/lib_fiber/samples-gui/WinFiber/WinFiberDlg.cpp
index c9d3f5766..4f32157d1 100644
--- a/lib_fiber/samples-gui/WinFiber/WinFiberDlg.cpp
+++ b/lib_fiber/samples-gui/WinFiber/WinFiberDlg.cpp
@@ -90,8 +90,8 @@ BEGIN_MESSAGE_MAP(CWinFiberDlg, CDialogEx)
ON_BN_CLICKED(IDC_START_HTTPD, &CWinFiberDlg::OnBnClickedStartHttpd)
ON_BN_CLICKED(IDOK, &CWinFiberDlg::OnBnClickedOk)
ON_BN_CLICKED(IDCANCEL, &CWinFiberDlg::OnBnClickedCancel)
-ON_BN_CLICKED(IDC_AWAIT_DNS, &CWinFiberDlg::OnBnClickedAwaitDns)
-ON_BN_CLICKED(IDC_RESOLVE, &CWinFiberDlg::OnBnClickedResolve)
+ ON_BN_CLICKED(IDC_AWAIT_DNS, &CWinFiberDlg::OnBnClickedAwaitDns)
+ ON_BN_CLICKED(IDC_RESOLVE, &CWinFiberDlg::OnBnClickedResolve)
END_MESSAGE_MAP()
// CWinFiberDlg 消息处理程序
diff --git a/lib_fiber/samples-gui/WinFiber/WinFiberDlg.h b/lib_fiber/samples-gui/WinFiber/WinFiberDlg.h
index b93b04315..7854b08d1 100644
--- a/lib_fiber/samples-gui/WinFiber/WinFiberDlg.h
+++ b/lib_fiber/samples-gui/WinFiber/WinFiberDlg.h
@@ -60,5 +60,5 @@ public:
afx_msg void OnBnClickedOk();
afx_msg void OnBnClickedCancel();
afx_msg void OnBnClickedAwaitDns();
-afx_msg void OnBnClickedResolve();
+ afx_msg void OnBnClickedResolve();
};