From 4963936de22acafa9a6e9bedf5cf6a0af260def0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=83=91=E6=A0=91=E6=96=B0?= Date: Sat, 28 Sep 2024 20:50:17 +0800 Subject: [PATCH] Add one windows GUI fiber demo. --- acl_cpp_vc2019.sln | 33 ++ .../samples-gui/SimpleWin/FiberClient.cpp | 29 ++ lib_fiber/samples-gui/SimpleWin/FiberClient.h | 18 + .../samples-gui/SimpleWin/FiberConnect.cpp | 57 +++ .../samples-gui/SimpleWin/FiberConnect.h | 16 + .../samples-gui/SimpleWin/FiberServer.cpp | 61 +++ lib_fiber/samples-gui/SimpleWin/FiberServer.h | 19 + lib_fiber/samples-gui/SimpleWin/Resource.h | 35 ++ lib_fiber/samples-gui/SimpleWin/SimpleWin.cpp | 359 ++++++++++++++++++ lib_fiber/samples-gui/SimpleWin/SimpleWin.h | 3 + lib_fiber/samples-gui/SimpleWin/SimpleWin.ico | Bin 0 -> 46227 bytes lib_fiber/samples-gui/SimpleWin/SimpleWin.rc | Bin 0 -> 8276 bytes .../samples-gui/SimpleWin/SimpleWin.vcxproj | 347 +++++++++++++++++ .../SimpleWin/SimpleWin.vcxproj.filters | 73 ++++ lib_fiber/samples-gui/SimpleWin/framework.h | 11 + lib_fiber/samples-gui/SimpleWin/pch.cpp | 5 + lib_fiber/samples-gui/SimpleWin/pch.h | 21 + lib_fiber/samples-gui/SimpleWin/small.ico | Bin 0 -> 46227 bytes lib_fiber/samples-gui/SimpleWin/targetver.h | 6 + 19 files changed, 1093 insertions(+) create mode 100644 lib_fiber/samples-gui/SimpleWin/FiberClient.cpp create mode 100644 lib_fiber/samples-gui/SimpleWin/FiberClient.h create mode 100644 lib_fiber/samples-gui/SimpleWin/FiberConnect.cpp create mode 100644 lib_fiber/samples-gui/SimpleWin/FiberConnect.h create mode 100644 lib_fiber/samples-gui/SimpleWin/FiberServer.cpp create mode 100644 lib_fiber/samples-gui/SimpleWin/FiberServer.h create mode 100644 lib_fiber/samples-gui/SimpleWin/Resource.h create mode 100644 lib_fiber/samples-gui/SimpleWin/SimpleWin.cpp create mode 100644 lib_fiber/samples-gui/SimpleWin/SimpleWin.h create mode 100644 lib_fiber/samples-gui/SimpleWin/SimpleWin.ico create mode 100644 lib_fiber/samples-gui/SimpleWin/SimpleWin.rc create mode 100644 lib_fiber/samples-gui/SimpleWin/SimpleWin.vcxproj create mode 100644 lib_fiber/samples-gui/SimpleWin/SimpleWin.vcxproj.filters create mode 100644 lib_fiber/samples-gui/SimpleWin/framework.h create mode 100644 lib_fiber/samples-gui/SimpleWin/pch.cpp create mode 100644 lib_fiber/samples-gui/SimpleWin/pch.h create mode 100644 lib_fiber/samples-gui/SimpleWin/small.ico create mode 100644 lib_fiber/samples-gui/SimpleWin/targetver.h diff --git a/acl_cpp_vc2019.sln b/acl_cpp_vc2019.sln index 7b417a58f..173a71c6a 100644 --- a/acl_cpp_vc2019.sln +++ b/acl_cpp_vc2019.sln @@ -167,6 +167,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "redis_builder", "app\redis_ EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "https_request", "lib_acl_cpp\samples\ssl\https_request\https_request_vc2019.vcxproj", "{4D42F462-A2FE-4B4A-A680-93668FA128A6}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SimpleWin", "lib_fiber\samples-gui\SimpleWin\SimpleWin.vcxproj", "{4D524F5F-31D7-42AB-915B-312CB67B0C18}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Mixed Platforms = Debug|Mixed Platforms @@ -925,6 +927,36 @@ Global {4D42F462-A2FE-4B4A-A680-93668FA128A6}.Template|Win32.Build.0 = Debug|Win32 {4D42F462-A2FE-4B4A-A680-93668FA128A6}.Template|x64.ActiveCfg = Debug|x64 {4D42F462-A2FE-4B4A-A680-93668FA128A6}.Template|x64.Build.0 = Debug|x64 + {4D524F5F-31D7-42AB-915B-312CB67B0C18}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 + {4D524F5F-31D7-42AB-915B-312CB67B0C18}.Debug|Mixed Platforms.Build.0 = Debug|Win32 + {4D524F5F-31D7-42AB-915B-312CB67B0C18}.Debug|Win32.ActiveCfg = Debug|Win32 + {4D524F5F-31D7-42AB-915B-312CB67B0C18}.Debug|Win32.Build.0 = Debug|Win32 + {4D524F5F-31D7-42AB-915B-312CB67B0C18}.Debug|x64.ActiveCfg = Debug|x64 + {4D524F5F-31D7-42AB-915B-312CB67B0C18}.Debug|x64.Build.0 = Debug|x64 + {4D524F5F-31D7-42AB-915B-312CB67B0C18}.DebugDll|Mixed Platforms.ActiveCfg = DebugDll|Win32 + {4D524F5F-31D7-42AB-915B-312CB67B0C18}.DebugDll|Mixed Platforms.Build.0 = DebugDll|Win32 + {4D524F5F-31D7-42AB-915B-312CB67B0C18}.DebugDll|Win32.ActiveCfg = DebugDll|Win32 + {4D524F5F-31D7-42AB-915B-312CB67B0C18}.DebugDll|Win32.Build.0 = DebugDll|Win32 + {4D524F5F-31D7-42AB-915B-312CB67B0C18}.DebugDll|x64.ActiveCfg = DebugDll|x64 + {4D524F5F-31D7-42AB-915B-312CB67B0C18}.DebugDll|x64.Build.0 = DebugDll|x64 + {4D524F5F-31D7-42AB-915B-312CB67B0C18}.Release|Mixed Platforms.ActiveCfg = Release|Win32 + {4D524F5F-31D7-42AB-915B-312CB67B0C18}.Release|Mixed Platforms.Build.0 = Release|Win32 + {4D524F5F-31D7-42AB-915B-312CB67B0C18}.Release|Win32.ActiveCfg = Release|Win32 + {4D524F5F-31D7-42AB-915B-312CB67B0C18}.Release|Win32.Build.0 = Release|Win32 + {4D524F5F-31D7-42AB-915B-312CB67B0C18}.Release|x64.ActiveCfg = Release|x64 + {4D524F5F-31D7-42AB-915B-312CB67B0C18}.Release|x64.Build.0 = Release|x64 + {4D524F5F-31D7-42AB-915B-312CB67B0C18}.Releasedll|Mixed Platforms.ActiveCfg = ReleaseDll|Win32 + {4D524F5F-31D7-42AB-915B-312CB67B0C18}.Releasedll|Mixed Platforms.Build.0 = ReleaseDll|Win32 + {4D524F5F-31D7-42AB-915B-312CB67B0C18}.Releasedll|Win32.ActiveCfg = ReleaseDll|Win32 + {4D524F5F-31D7-42AB-915B-312CB67B0C18}.Releasedll|Win32.Build.0 = ReleaseDll|Win32 + {4D524F5F-31D7-42AB-915B-312CB67B0C18}.Releasedll|x64.ActiveCfg = ReleaseDll|x64 + {4D524F5F-31D7-42AB-915B-312CB67B0C18}.Releasedll|x64.Build.0 = ReleaseDll|x64 + {4D524F5F-31D7-42AB-915B-312CB67B0C18}.Template|Mixed Platforms.ActiveCfg = Debug|Win32 + {4D524F5F-31D7-42AB-915B-312CB67B0C18}.Template|Mixed Platforms.Build.0 = Debug|Win32 + {4D524F5F-31D7-42AB-915B-312CB67B0C18}.Template|Win32.ActiveCfg = Debug|Win32 + {4D524F5F-31D7-42AB-915B-312CB67B0C18}.Template|Win32.Build.0 = Debug|Win32 + {4D524F5F-31D7-42AB-915B-312CB67B0C18}.Template|x64.ActiveCfg = Debug|x64 + {4D524F5F-31D7-42AB-915B-312CB67B0C18}.Template|x64.Build.0 = Debug|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -964,6 +996,7 @@ Global {45276293-D169-4D73-8930-F255C09DA976} = {30B69273-9D47-4AD6-B1C5-CF362F9C6D80} {D90DCF51-E219-4BD8-A032-076335675F58} = {30B69273-9D47-4AD6-B1C5-CF362F9C6D80} {4D42F462-A2FE-4B4A-A680-93668FA128A6} = {AB838366-C278-426E-ADDF-BE3A32BADD3E} + {4D524F5F-31D7-42AB-915B-312CB67B0C18} = {1CB30F2E-2587-43E7-A3CF-787783FB6924} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {40FA3A5B-123F-4EC0-9EEB-8A9C17BF573B} diff --git a/lib_fiber/samples-gui/SimpleWin/FiberClient.cpp b/lib_fiber/samples-gui/SimpleWin/FiberClient.cpp new file mode 100644 index 000000000..e05cf7526 --- /dev/null +++ b/lib_fiber/samples-gui/SimpleWin/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/SimpleWin/FiberClient.h b/lib_fiber/samples-gui/SimpleWin/FiberClient.h new file mode 100644 index 000000000..c17cee8eb --- /dev/null +++ b/lib_fiber/samples-gui/SimpleWin/FiberClient.h @@ -0,0 +1,18 @@ +#pragma once + +#include + +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/SimpleWin/FiberConnect.cpp b/lib_fiber/samples-gui/SimpleWin/FiberConnect.cpp new file mode 100644 index 000000000..ccecd9f53 --- /dev/null +++ b/lib_fiber/samples-gui/SimpleWin/FiberConnect.cpp @@ -0,0 +1,57 @@ +#include "pch.h" +#include "FiberConnect.h" + +CFiberConnect::CFiberConnect(const char* ip, int port, int count) +: ip_(ip) +, port_(port) +, count_(count) +{ +} + +CFiberConnect::~CFiberConnect(void) {} + +bool CFiberConnect::Start(void) +{ + struct sockaddr_in in; + in.sin_family = AF_INET; + in.sin_port = htons(port_); + if (inet_pton(AF_INET, ip_.c_str(), &in.sin_addr) == -1) { + printf("invalid ip = % s\r\n", ip_.c_str()); + return false; + } + + SOCKET sock = socket(AF_INET, SOCK_STREAM, 0); + if (sock == INVALID_SOCKET) { + return false; + } + + if (connect(sock, (const sockaddr*)&in, sizeof(in)) == -1) { + closesocket(sock); + printf("connect %s:%d error\r\n", ip_.c_str(), port_); + return false; + } + + printf(">>>connect %s:%d ok\r\n", ip_.c_str(), port_); + + const char data[] = "hello world!\r\n"; + char buf[256]; + int i; + for (i = 0; i < count_; i++) { + int ret = send(sock, data, sizeof(data) - 1, 0); + if (ret == -1) { + break; + } + ret = recv(sock, buf, sizeof(buf), 0); + if (ret <= 0) { + break; + } + if (i % 1000 == 0) { + printf(">>>current io=%d, thread=%d, fiber=%d\r\n", + i, GetCurrentThreadId(), acl::fiber::self()); + } + } + + closesocket(sock); + printf(">>>All over count=%d, %d\r\n", count_, i); + return true; +} diff --git a/lib_fiber/samples-gui/SimpleWin/FiberConnect.h b/lib_fiber/samples-gui/SimpleWin/FiberConnect.h new file mode 100644 index 000000000..989ea2da2 --- /dev/null +++ b/lib_fiber/samples-gui/SimpleWin/FiberConnect.h @@ -0,0 +1,16 @@ +#pragma once + +class CFiberConnect +{ +public: + CFiberConnect(const char* ip, int port, int count); + ~CFiberConnect(void); + + bool Start(void); + +private: + std::string ip_; + int port_; + int count_; +}; + diff --git a/lib_fiber/samples-gui/SimpleWin/FiberServer.cpp b/lib_fiber/samples-gui/SimpleWin/FiberServer.cpp new file mode 100644 index 000000000..1a15e1168 --- /dev/null +++ b/lib_fiber/samples-gui/SimpleWin/FiberServer.cpp @@ -0,0 +1,61 @@ +#include "pch.h" +#include "FiberClient.h" +#include "FiberServer.h" + +CFiberServer::CFiberServer(bool autoDestroy /* = true */) +: m_sock(INVALID_SOCKET) +, m_autoDestroy(autoDestroy) +{ +} + +CFiberServer::~CFiberServer(void) +{ + if (m_sock != INVALID_SOCKET) { + closesocket(m_sock); + } +} + +bool CFiberServer::BindAndListen(int port, const std::string& addr) +{ + SOCKET sock = socket(AF_INET, SOCK_STREAM, 0); + if (sock == INVALID_SOCKET) { + return false; + } + + struct sockaddr_in in; + in.sin_family = AF_INET; + in.sin_port = htons(port); + if (inet_pton(AF_INET, addr.c_str(), &in.sin_addr) == -1) { + closesocket(sock); + return false; + } + + if (bind(sock, (const sockaddr*)&in, sizeof(in)) == -1) { + closesocket(sock); + return false; + } + + if (listen(sock, 128) == -1) { + return false; + } + + m_sock = sock; + return true; +} + +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(); + } + + if (m_autoDestroy) { + delete this; + } +} diff --git a/lib_fiber/samples-gui/SimpleWin/FiberServer.h b/lib_fiber/samples-gui/SimpleWin/FiberServer.h new file mode 100644 index 000000000..7da4a0e15 --- /dev/null +++ b/lib_fiber/samples-gui/SimpleWin/FiberServer.h @@ -0,0 +1,19 @@ +#pragma once + +class CFiberServer : public acl::fiber +{ +public: + CFiberServer(bool autoDestroy = true); + ~CFiberServer(void); + + bool BindAndListen(int port, const std::string& addr); + +protected: + // @override + void run(void); + +private: + SOCKET m_sock; + bool m_autoDestroy; +}; + diff --git a/lib_fiber/samples-gui/SimpleWin/Resource.h b/lib_fiber/samples-gui/SimpleWin/Resource.h new file mode 100644 index 000000000..d678feefb --- /dev/null +++ b/lib_fiber/samples-gui/SimpleWin/Resource.h @@ -0,0 +1,35 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ 生成的包含文件。 +// 供 SimpleWin.rc 使用 +// +#define IDC_MYICON 2 +#define IDD_SIMPLEWIN_DIALOG 102 +#define IDS_APP_TITLE 103 +#define IDD_ABOUTBOX 103 +#define IDM_ABOUT 104 +#define IDM_EXIT 105 +#define IDI_SIMPLEWIN 107 +#define IDI_SMALL 108 +#define IDC_SIMPLEWIN 109 +#define IDR_MAINFRAME 128 +#define ID_Menu 32771 +#define IDM_START_LISTENER 32775 +#define IDM_STOP_LISTENER 32776 +#define IDM_OPEN_DOS 32777 +#define IDM_CLOSE_DOS 32778 +#define IDM_START_CONNECT 32779 +#define IDM_RESOLVE_THREAD 32780 +#define IDM_RESOLVE_FIBER 32781 +#define IDC_STATIC -1 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NO_MFC 1 +#define _APS_NEXT_RESOURCE_VALUE 129 +#define _APS_NEXT_COMMAND_VALUE 32782 +#define _APS_NEXT_CONTROL_VALUE 1000 +#define _APS_NEXT_SYMED_VALUE 110 +#endif +#endif diff --git a/lib_fiber/samples-gui/SimpleWin/SimpleWin.cpp b/lib_fiber/samples-gui/SimpleWin/SimpleWin.cpp new file mode 100644 index 000000000..3694a8242 --- /dev/null +++ b/lib_fiber/samples-gui/SimpleWin/SimpleWin.cpp @@ -0,0 +1,359 @@ +// SimpleWin.cpp : 定义应用程序的入口点。 +// + +#include "pch.h" +#include "framework.h" +#include "FiberServer.h" +#include "FiberConnect.h" +#include "SimpleWin.h" + +#define MAX_LOADSTRING 100 + +// 全局变量: +HINSTANCE hInst; // 当前实例 +WCHAR szTitle[MAX_LOADSTRING]; // 标题栏文本 +WCHAR szWindowClass[MAX_LOADSTRING]; // 主窗口类名 +CFiberServer* fiber_server = NULL; // 监听协程对象 +FILE* dos_handle = NULL; // DOS 窗口句柄 +const char* server_addr = "127.0.0.1"; +int server_port = 8088; + +// 此代码模块中包含的函数的前向声明: +ATOM MyRegisterClass(HINSTANCE hInstance); +BOOL InitInstance(HINSTANCE, int); +LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); +INT_PTR CALLBACK About(HWND, UINT, WPARAM, LPARAM); + +int APIENTRY wWinMain(_In_ HINSTANCE hInstance, + _In_opt_ HINSTANCE hPrevInstance, + _In_ LPWSTR lpCmdLine, + _In_ int nCmdShow) +{ + UNREFERENCED_PARAMETER(hPrevInstance); + UNREFERENCED_PARAMETER(lpCmdLine); + + // TODO: 在此处放置代码。} + + // 初始化全局字符串 + LoadStringW(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING); + LoadStringW(hInstance, IDC_SIMPLEWIN, szWindowClass, MAX_LOADSTRING); + MyRegisterClass(hInstance); + + // 执行应用程序初始化: + if (!InitInstance (hInstance, nCmdShow)) { + return FALSE; + } + + HACCEL hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_SIMPLEWIN)); + + MSG msg; + + // 主消息循环: + while (GetMessage(&msg, nullptr, 0, 0)) { + if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg)) { + TranslateMessage(&msg); + DispatchMessage(&msg); + } + } + + return (int) msg.wParam; +} + +// +// 函数: MyRegisterClass() +// +// 目标: 注册窗口类。 +// +ATOM MyRegisterClass(HINSTANCE hInstance) +{ + WNDCLASSEXW wcex; + + wcex.cbSize = sizeof(WNDCLASSEX); + + wcex.style = CS_HREDRAW | CS_VREDRAW; + wcex.lpfnWndProc = WndProc; + wcex.cbClsExtra = 0; + wcex.cbWndExtra = 0; + wcex.hInstance = hInstance; + wcex.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_SIMPLEWIN)); + wcex.hCursor = LoadCursor(nullptr, IDC_ARROW); + wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); + wcex.lpszMenuName = MAKEINTRESOURCEW(IDC_SIMPLEWIN); + wcex.lpszClassName = szWindowClass; + wcex.hIconSm = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_SMALL)); + + return RegisterClassExW(&wcex); +} + +static bool InitSocket(void) +{ + WORD version = 0; + WSADATA data; + + FillMemory(&data, sizeof(WSADATA), 0); + + version = MAKEWORD(2, 0); + + if (WSAStartup(version, &data) != 0) { + return false; + } + if (LOBYTE(data.wVersion) != 2 || HIBYTE(data.wVersion) != 0) { + WSACleanup(); + return false; + } + + return true; +} + +// +// 函数: InitInstance(HINSTANCE, int) +// +// 目标: 保存实例句柄并创建主窗口 +// +// 注释: +// +// 在此函数中,我们在全局变量中保存实例句柄并 +// 创建和显示主程序窗口。 +// +BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) +{ + hInst = hInstance; // 将实例句柄存储在全局变量中 + + HWND hWnd = CreateWindowW(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW, + CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, nullptr, nullptr, hInstance, nullptr); + + if (!hWnd) { + return FALSE; + } + + ShowWindow(hWnd, nCmdShow); + UpdateWindow(hWnd); + + HMENU hMenu = GetMenu(hWnd); + EnableMenuItem(hMenu, IDM_STOP_LISTENER, MF_DISABLED); + EnableMenuItem(hMenu, IDM_OPEN_DOS, MF_ENABLED); + EnableMenuItem(hMenu, IDM_CLOSE_DOS, MF_DISABLED); + + // 设置协程调度的事件引擎,同时将协程调度设为自动启动模式,不能在进程初始化时启动 + // 协程调试器,必须在界面消息引擎正常运行后才启动协程调度器! + acl::fiber::init(acl::FIBER_EVENT_T_WMSG, true); + acl::fiber::winapi_hook(); + + InitSocket(); + + return TRUE; +} + +static bool GetHostByname(const char* name, std::vector* addrs) +{ + printf("\r\n"); + printf(">>>call gethostbyname, name=%s, thread=%d\r\n", name, GetCurrentThreadId()); + struct hostent* ent = gethostbyname(name); + if (ent == NULL) { + printf("gethostbyname error, name=%s, thread=%d\r\n", name, GetCurrentThreadId()); + return false; + } + + for (int i = 0; ent->h_addr_list[i]; i++) { + char* addr = ent->h_addr_list[i]; + char ip[64]; + const char* ptr = inet_ntop(ent->h_addrtype, addr, ip, sizeof(ip)); + if (ptr) { + addrs->push_back(ptr); + } + else { + printf(">>>inet_ntop error\r\n"); + } + } + + return true; +} + +static void GetAddrInfo(const std::string& name) +{ + struct addrinfo* res0, * res; + int ret = getaddrinfo(name.c_str(), NULL, NULL, &res0); + if (ret != 0) { + printf("getaddrinfo error=%d, %s, domain=%s\r\n", + ret, gai_strerrorA(ret), name.c_str()); + if (res0) { + freeaddrinfo(res0); + } + return; + } + + printf("\r\n"); + printf("getaddrinfo: domain=%s, thread=%d\r\n", name.c_str(), GetCurrentThreadId()); + for (res = res0; res; res = res->ai_next) { + const void* addr; + char ip[64]; + if (res->ai_family == AF_INET) { + const struct sockaddr_in* in = + (const struct sockaddr_in*)res->ai_addr; + addr = (const void*)&in->sin_addr; + } else if (res->ai_family == AF_INET6) { + const struct sockaddr_in6* in = + (const struct sockaddr_in6*)res->ai_addr; + addr = (const void*)&in->sin6_addr; + } else { + printf("Unknown ai_family=%d\r\n", res->ai_family); + continue; + } + + if (inet_ntop(res->ai_family, addr, ip, sizeof(ip)) != NULL) { + printf(">>ip=%s\r\n", ip); + } else { + printf(">>inet_ntop error\r\n"); + } + } +} + +// +// 函数: WndProc(HWND, UINT, WPARAM, LPARAM) +// +// 目标: 处理主窗口的消息。 +// +// WM_COMMAND - 处理应用程序菜单 +// WM_PAINT - 绘制主窗口 +// WM_DESTROY - 发送退出消息并返回 +// +// +LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) +{ + switch (message) { + case WM_COMMAND: + { + int wmId = LOWORD(wParam); + // 分析菜单选择: + switch (wmId) { + case IDM_ABOUT: + DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About); + break; + case IDM_EXIT: + DestroyWindow(hWnd); + break; + case IDM_START_LISTENER: + { + fiber_server = new CFiberServer(); + if (fiber_server->BindAndListen(server_port, server_addr)) { + HMENU hMenu = GetMenu(hWnd); + EnableMenuItem(hMenu, IDM_START_LISTENER, MF_DISABLED); + EnableMenuItem(hMenu, IDM_STOP_LISTENER, MF_ENABLED); + printf(">>>Start fiber to listen on %s:%d, thread=%d\r\n", + server_addr, server_port, GetCurrentThreadId()); + fiber_server->start(); + } else { + delete fiber_server; + fiber_server = NULL; + } + } + break; + case IDM_STOP_LISTENER: + { + if (fiber_server) { + fiber_server->kill(); + fiber_server = NULL; + printf(">>>Listener fiber stopped!\r\n"); + } + HMENU hMenu = GetMenu(hWnd); + EnableMenuItem(hMenu, IDM_START_LISTENER, MF_ENABLED); + EnableMenuItem(hMenu, IDM_STOP_LISTENER, MF_DISABLED); + } + break; + case IDM_START_CONNECT: + for (int i = 0; i < 10; i++) { + go[=] { + CFiberConnect client(server_addr, server_port, 10000); + client.Start(); + }; + } + break; + case IDM_RESOLVE_THREAD: + go[=]{ + const std::string name = "www.google.com"; + std::vector addrs; + go_wait[&] { + if (!GetHostByname(name.c_str(), &addrs)) { + printf(">>>resolve DNS error, name=%s\r\n", name.c_str()); + } + }; + + printf(">>>resolve done: name=%s, result count=%zd, thread=%d\r\n", + name.c_str(), addrs.size(), GetCurrentThreadId()); + + for (std::vector::const_iterator cit = addrs.begin(); + cit != addrs.end(); ++cit) { + printf(">>>ip=%s\r\n", (*cit).c_str()); + } + }; + break; + case IDM_RESOLVE_FIBER: + { + std::string name = "www.google.com"; + go[=]{ + GetAddrInfo(name); + }; + } + break; + case IDM_OPEN_DOS: + if (dos_handle == NULL) { + AllocConsole(); + dos_handle = _wfreopen(_T("CONOUT$"), _T("w+t"), stdout); + if (dos_handle != NULL) { + HMENU hMenu = GetMenu(hWnd); + EnableMenuItem(hMenu, IDM_OPEN_DOS, MF_DISABLED); + EnableMenuItem(hMenu, IDM_CLOSE_DOS, MF_ENABLED); + printf("DOS opened, current thread=%d!\r\n", GetCurrentThreadId()); + } + } + break; + case IDM_CLOSE_DOS: + if (dos_handle) { + fclose(dos_handle); + dos_handle = NULL; + FreeConsole(); + HMENU hMenu = GetMenu(hWnd); + EnableMenuItem(hMenu, IDM_OPEN_DOS, MF_ENABLED); + EnableMenuItem(hMenu, IDM_CLOSE_DOS, MF_DISABLED); + } + break; + default: + return DefWindowProc(hWnd, message, wParam, lParam); + } + } + break; + case WM_PAINT: + { + PAINTSTRUCT ps; + HDC hdc = BeginPaint(hWnd, &ps); + // TODO: 在此处添加使用 hdc 的任何绘图代码... + EndPaint(hWnd, &ps); + } + break; + case WM_DESTROY: + acl::fiber::schedule_stop(); + PostQuitMessage(0); + break; + default: + return DefWindowProc(hWnd, message, wParam, lParam); + } + return 0; +} + +// “关于”框的消息处理程序。 +INT_PTR CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) +{ + UNREFERENCED_PARAMETER(lParam); + switch (message) { + case WM_INITDIALOG: + return (INT_PTR)TRUE; + + case WM_COMMAND: + if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL) { + EndDialog(hDlg, LOWORD(wParam)); + return (INT_PTR)TRUE; + } + break; + } + return (INT_PTR)FALSE; +} diff --git a/lib_fiber/samples-gui/SimpleWin/SimpleWin.h b/lib_fiber/samples-gui/SimpleWin/SimpleWin.h new file mode 100644 index 000000000..d00d47e78 --- /dev/null +++ b/lib_fiber/samples-gui/SimpleWin/SimpleWin.h @@ -0,0 +1,3 @@ +#pragma once + +#include "resource.h" diff --git a/lib_fiber/samples-gui/SimpleWin/SimpleWin.ico b/lib_fiber/samples-gui/SimpleWin/SimpleWin.ico new file mode 100644 index 0000000000000000000000000000000000000000..b3ec03bd617f32e58128fa977fd6ac9605124f4b GIT binary patch literal 46227 zcmeG_3s@7^(i=en%FAlCDneRC>$M_k6<<8GwYF8!R&T*-0nuNr4^Sy8A`n5bmRqT{ zK5o_G(b(u^yZQ8UkW5(>;x9{lDqk(~eD_5>eNlDqb zapUaSv*o2vfswy>543gya=eTKJ}bJsb08RyLkrbzg~EDF)&yx{%~3lMOmjI z2r>fq&!#BLn;*SDdg=``Ge%vn(_ zHtGJ!s?^=xQ)VolXES2J@MURR$8V^WUk}@~H&O9u;)XhDr?A*8NV1jpnGS9@R3zjJlMS^bL*v(^3?X@it_xf^eOAIF1)HHQBqYfeohaonv$Cm)jId+ zOVxIDS1y%GYM&OxMbuR%tEwZv6c&U_detcl+-(L0I+vtX6%TS(6-esN{F)w7bMOD| zOWW0^33nGuWA6=U_k~Z`_8H2%Xi~K^>vZ`oLJj;+dof+Rb*dtUE!B9(#yAE zinCMDvqwpLLl>`DVqzVqn&SNSS4zywZ(O!oQ5+P}ZqDo*iQywp2?H;6m*1FM+v(ik zKuPue2llH<lpzzQC0ZQ&fW!@2| zCA+sBFDXoZ&s`OJt!UeG*-;nSw@IqwS!bgXV{4brPy0l^ru(7V((LEr;MieH9$eol ztF#|gWOnaxM#TNAhX?ycZV#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.vcxproj new file mode 100644 index 000000000..5e6377610 --- /dev/null +++ b/lib_fiber/samples-gui/SimpleWin/SimpleWin.vcxproj @@ -0,0 +1,347 @@ + + + + + DebugDll + Win32 + + + DebugDll + x64 + + + Debug + Win32 + + + ReleaseDll + Win32 + + + ReleaseDll + x64 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 16.0 + Win32Proj + {4d524f5f-31d7-42ab-915b-312cb67b0c18} + SimpleWin + 10.0 + + + + Application + true + v142 + Unicode + + + Application + true + v142 + Unicode + + + Application + false + v142 + true + Unicode + + + Application + false + v142 + true + Unicode + + + Application + true + v142 + Unicode + + + Application + true + v142 + Unicode + + + Application + false + v142 + true + Unicode + + + Application + false + v142 + true + Unicode + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + true + + + true + + + false + + + false + + + true + + + true + + + false + + + false + + + + Level3 + true + WIN32;_DEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS;_WINSOCK_DEPRECATED_NO_WARNINGS;%(PreprocessorDefinitions) + true + Use + pch.h + ..\..\cpp\include;..\..\..\lib_acl_cpp\include + /Zc:__cplusplus %(AdditionalOptions) + + + Windows + true + $(OutDir);%(AdditionalLibraryDirectories) + libfiber_cpp.lib;lib_acl_cpp.lib;lib_protocol.lib;lib_acl.lib;libfiber.lib;%(AdditionalDependencies) + + + + + Level3 + true + WIN32;_DEBUG;_WINDOWS;FIBER_CPP_DLL;ACL_CPP_DLL;_CRT_SECURE_NO_WARNINGS;_WINSOCK_DEPRECATED_NO_WARNINGS;%(PreprocessorDefinitions) + true + Use + pch.h + ..\..\cpp\include;..\..\..\lib_acl_cpp\include + /Zc:__cplusplus %(AdditionalOptions) + + + Windows + true + $(OutDir);%(AdditionalLibraryDirectories) + ws2_32.lib;libfiber_cpp.lib;lib_acl_cpp.lib;lib_protocol.lib;lib_acl.lib;libfiber.lib;%(AdditionalDependencies) + + + + + Level3 + true + true + true + WIN32;NDEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS;_WINSOCK_DEPRECATED_NO_WARNINGS;%(PreprocessorDefinitions) + true + Use + pch.h + ..\..\cpp\include;..\..\..\lib_acl_cpp\include + /Zc:__cplusplus %(AdditionalOptions) + + + Windows + true + true + true + libfiber_cpp.lib;lib_acl_cpp.lib;lib_protocol.lib;lib_acl.lib;libfiber.lib;%(AdditionalDependencies) + $(OutDir);%(AdditionalLibraryDirectories) + + + + + Level3 + true + true + true + WIN32;NDEBUG;_WINDOWS;FIBER_CPP_DLL;ACL_CPP_DLL;_CRT_SECURE_NO_WARNINGS;_WINSOCK_DEPRECATED_NO_WARNINGS;%(PreprocessorDefinitions) + true + Use + pch.h + ..\..\cpp\include;..\..\..\lib_acl_cpp\include + /Zc:__cplusplus %(AdditionalOptions) + + + Windows + true + true + true + $(OutDir);%(AdditionalLibraryDirectories) + ws2_32.lib;libfiber_cpp.lib;lib_acl_cpp.lib;lib_protocol.lib;lib_acl.lib;libfiber.lib;%(AdditionalDependencies) + + + + + Level3 + true + _DEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS;_WINSOCK_DEPRECATED_NO_WARNINGS;%(PreprocessorDefinitions) + true + Use + pch.h + ..\..\cpp\include;..\..\..\lib_acl_cpp\include + /Zc:__cplusplus %(AdditionalOptions) + + + Windows + true + $(OutDir);%(AdditionalLibraryDirectories) + libfiber_cpp.lib;lib_acl_cpp.lib;lib_protocol.lib;lib_acl.lib;libfiber.lib;%(AdditionalDependencies) + + + + + Level3 + true + _DEBUG;_WINDOWS;FIBER_CPP_DLL;ACL_CPP_DLL;_CRT_SECURE_NO_WARNINGS;_WINSOCK_DEPRECATED_NO_WARNINGS;%(PreprocessorDefinitions) + true + Use + pch.h + ..\..\cpp\include;..\..\..\lib_acl_cpp\include + /Zc:__cplusplus %(AdditionalOptions) + + + Windows + true + ws2_32.lib;libfiber_cpp.lib;lib_acl_cpp.lib;lib_protocol.lib;lib_acl.lib;libfiber.lib;%(AdditionalDependencies) + $(OutDir);%(AdditionalLibraryDirectories) + + + + + Level3 + true + true + true + NDEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS;_WINSOCK_DEPRECATED_NO_WARNINGS;%(PreprocessorDefinitions) + true + Use + pch.h + ..\..\cpp\include;..\..\..\lib_acl_cpp\include + /Zc:__cplusplus %(AdditionalOptions) + + + Windows + true + true + true + $(OutDir);%(AdditionalLibraryDirectories) + libfiber_cpp.lib;lib_acl_cpp.lib;lib_protocol.lib;lib_acl.lib;libfiber.lib;%(AdditionalDependencies) + + + + + Level3 + true + true + true + NDEBUG;_WINDOWS;FIBER_CPP_DLL;ACL_CPP_DLL;_CRT_SECURE_NO_WARNINGS;_WINSOCK_DEPRECATED_NO_WARNINGS;%(PreprocessorDefinitions) + true + Use + pch.h + ..\..\cpp\include;..\..\..\lib_acl_cpp\include + /Zc:__cplusplus %(AdditionalOptions) + + + Windows + true + true + true + $(OutDir);%(AdditionalLibraryDirectories) + ws2_32.lib;libfiber_cpp.lib;lib_acl_cpp.lib;lib_protocol.lib;lib_acl.lib;libfiber.lib;%(AdditionalDependencies) + + + + + + + + + + + + + + + + + + Create + Create + Create + Create + Create + Create + Create + Create + + + + + + + + + + + + + + \ No newline at end of file diff --git a/lib_fiber/samples-gui/SimpleWin/SimpleWin.vcxproj.filters b/lib_fiber/samples-gui/SimpleWin/SimpleWin.vcxproj.filters new file mode 100644 index 000000000..b289c2c77 --- /dev/null +++ b/lib_fiber/samples-gui/SimpleWin/SimpleWin.vcxproj.filters @@ -0,0 +1,73 @@ + + + + + {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/SimpleWin/framework.h b/lib_fiber/samples-gui/SimpleWin/framework.h new file mode 100644 index 000000000..cfdabe839 --- /dev/null +++ b/lib_fiber/samples-gui/SimpleWin/framework.h @@ -0,0 +1,11 @@ +#pragma once + +#include "targetver.h" +#define WIN32_LEAN_AND_MEAN // 从 Windows 头文件中排除极少使用的内容 +// Windows 头文件 +#include +// C 运行时头文件 +#include +#include +#include +#include diff --git a/lib_fiber/samples-gui/SimpleWin/pch.cpp b/lib_fiber/samples-gui/SimpleWin/pch.cpp new file mode 100644 index 000000000..b6fb8f4ab --- /dev/null +++ b/lib_fiber/samples-gui/SimpleWin/pch.cpp @@ -0,0 +1,5 @@ +// pch.cpp: 与预编译标头对应的源文件 + +#include "pch.h" + +// 当使用预编译的头时,需要使用此源文件,编译才能成功。 diff --git a/lib_fiber/samples-gui/SimpleWin/pch.h b/lib_fiber/samples-gui/SimpleWin/pch.h new file mode 100644 index 000000000..d9c48c7c7 --- /dev/null +++ b/lib_fiber/samples-gui/SimpleWin/pch.h @@ -0,0 +1,21 @@ +// pch.h: 这是预编译标头文件。 +// 下方列出的文件仅编译一次,提高了将来生成的生成性能。 +// 这还将影响 IntelliSense 性能,包括代码完成和许多代码浏览功能。 +// 但是,如果此处列出的文件中的任何一个在生成之间有更新,它们全部都将被重新编译。 +// 请勿在此处添加要频繁更新的文件,这将使得性能优势无效。 + +#ifndef PCH_H +#define PCH_H + +// 添加要在此处预编译的标头 +#include +#include +#include +#include + +#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/SimpleWin/small.ico b/lib_fiber/samples-gui/SimpleWin/small.ico new file mode 100644 index 0000000000000000000000000000000000000000..b3ec03bd617f32e58128fa977fd6ac9605124f4b GIT binary patch literal 46227 zcmeG_3s@7^(i=en%FAlCDneRC>$M_k6<<8GwYF8!R&T*-0nuNr4^Sy8A`n5bmRqT{ zK5o_G(b(u^yZQ8UkW5(>;x9{lDqk(~eD_5>eNlDqb zapUaSv*o2vfswy>543gya=eTKJ}bJsb08RyLkrbzg~EDF)&yx{%~3lMOmjI z2r>fq&!#BLn;*SDdg=``Ge%vn(_ zHtGJ!s?^=xQ)VolXES2J@MURR$8V^WUk}@~H&O9u;)XhDr?A*8NV1jpnGS9@R3zjJlMS^bL*v(^3?X@it_xf^eOAIF1)HHQBqYfeohaonv$Cm)jId+ zOVxIDS1y%GYM&OxMbuR%tEwZv6c&U_detcl+-(L0I+vtX6%TS(6-esN{F)w7bMOD| zOWW0^33nGuWA6=U_k~Z`_8H2%Xi~K^>vZ`oLJj;+dof+Rb*dtUE!B9(#yAE zinCMDvqwpLLl>`DVqzVqn&SNSS4zywZ(O!oQ5+P}ZqDo*iQywp2?H;6m*1FM+v(ik zKuPue2llH<lpzzQC0ZQ&fW!@2| zCA+sBFDXoZ&s`OJt!UeG*-;nSw@IqwS!bgXV{4brPy0l^ru(7V((LEr;MieH9$eol ztF#|gWOnaxM#TNAhX?ycZV#28>t6U2vUhev*6X=!y^Cyctm@*mSw&||2b89k2T12S zs5WPQGwMKAfV2p*(!)o6B2$E!rv#ZHO0PlduB^0pWIyVm*{I^DzUzC8eCW8? z=BFT&pQ;pzy=-=tzc!;ZH7GzD1dQ^-Q+y&NpT{jR`AMZnyl1oX>1)aw`%wjE%C9pb z{^#7`jy{pUx+;`bicdg?AKvS8+Eg+s!X*4ofn?BwTUi5A9Wt#IhcW`Cp;u~zX&I+$ z6~0HjCOi(CTN{<%GdDz;c&lIU&Wcl8MG?v_mEWu%n^Nd_qUfnFly0f|W~(eABVuOa zHt$DAeIrLYsMenG_dlE&X7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