mirror of
https://gitee.com/acl-dev/acl.git
synced 2024-11-29 10:27:39 +08:00
Add one windows GUI fiber demo.
This commit is contained in:
parent
037f55fbb9
commit
4963936de2
@ -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}
|
||||
|
29
lib_fiber/samples-gui/SimpleWin/FiberClient.cpp
Normal file
29
lib_fiber/samples-gui/SimpleWin/FiberClient.cpp
Normal file
@ -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;
|
||||
}
|
18
lib_fiber/samples-gui/SimpleWin/FiberClient.h
Normal file
18
lib_fiber/samples-gui/SimpleWin/FiberClient.h
Normal file
@ -0,0 +1,18 @@
|
||||
#pragma once
|
||||
|
||||
#include <WinSock2.h>
|
||||
|
||||
class CFiberClient : public acl::fiber
|
||||
{
|
||||
public:
|
||||
CFiberClient(SOCKET sock);
|
||||
|
||||
private:
|
||||
~CFiberClient(void);
|
||||
|
||||
protected:
|
||||
void run(void);
|
||||
|
||||
private:
|
||||
SOCKET m_sock;
|
||||
};
|
57
lib_fiber/samples-gui/SimpleWin/FiberConnect.cpp
Normal file
57
lib_fiber/samples-gui/SimpleWin/FiberConnect.cpp
Normal file
@ -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;
|
||||
}
|
16
lib_fiber/samples-gui/SimpleWin/FiberConnect.h
Normal file
16
lib_fiber/samples-gui/SimpleWin/FiberConnect.h
Normal file
@ -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_;
|
||||
};
|
||||
|
61
lib_fiber/samples-gui/SimpleWin/FiberServer.cpp
Normal file
61
lib_fiber/samples-gui/SimpleWin/FiberServer.cpp
Normal file
@ -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;
|
||||
}
|
||||
}
|
19
lib_fiber/samples-gui/SimpleWin/FiberServer.h
Normal file
19
lib_fiber/samples-gui/SimpleWin/FiberServer.h
Normal file
@ -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;
|
||||
};
|
||||
|
35
lib_fiber/samples-gui/SimpleWin/Resource.h
Normal file
35
lib_fiber/samples-gui/SimpleWin/Resource.h
Normal file
@ -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
|
359
lib_fiber/samples-gui/SimpleWin/SimpleWin.cpp
Normal file
359
lib_fiber/samples-gui/SimpleWin/SimpleWin.cpp
Normal file
@ -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<std::string>* 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<std::string> 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<std::string>::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;
|
||||
}
|
3
lib_fiber/samples-gui/SimpleWin/SimpleWin.h
Normal file
3
lib_fiber/samples-gui/SimpleWin/SimpleWin.h
Normal file
@ -0,0 +1,3 @@
|
||||
#pragma once
|
||||
|
||||
#include "resource.h"
|
BIN
lib_fiber/samples-gui/SimpleWin/SimpleWin.ico
Normal file
BIN
lib_fiber/samples-gui/SimpleWin/SimpleWin.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 45 KiB |
BIN
lib_fiber/samples-gui/SimpleWin/SimpleWin.rc
Normal file
BIN
lib_fiber/samples-gui/SimpleWin/SimpleWin.rc
Normal file
Binary file not shown.
347
lib_fiber/samples-gui/SimpleWin/SimpleWin.vcxproj
Normal file
347
lib_fiber/samples-gui/SimpleWin/SimpleWin.vcxproj
Normal file
@ -0,0 +1,347 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="DebugDll|Win32">
|
||||
<Configuration>DebugDll</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="DebugDll|x64">
|
||||
<Configuration>DebugDll</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="ReleaseDll|Win32">
|
||||
<Configuration>ReleaseDll</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="ReleaseDll|x64">
|
||||
<Configuration>ReleaseDll</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>16.0</VCProjectVersion>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<ProjectGuid>{4d524f5f-31d7-42ab-915b-312cb67b0c18}</ProjectGuid>
|
||||
<RootNamespace>SimpleWin</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DebugDll|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseDll|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DebugDll|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseDll|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='DebugDll|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseDll|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='DebugDll|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseDll|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DebugDll|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseDll|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DebugDll|x64'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseDll|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS;_WINSOCK_DEPRECATED_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
<AdditionalIncludeDirectories>..\..\cpp\include;..\..\..\lib_acl_cpp\include</AdditionalIncludeDirectories>
|
||||
<AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalLibraryDirectories>$(OutDir);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<AdditionalDependencies>libfiber_cpp.lib;lib_acl_cpp.lib;lib_protocol.lib;lib_acl.lib;libfiber.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='DebugDll|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;FIBER_CPP_DLL;ACL_CPP_DLL;_CRT_SECURE_NO_WARNINGS;_WINSOCK_DEPRECATED_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
<AdditionalIncludeDirectories>..\..\cpp\include;..\..\..\lib_acl_cpp\include</AdditionalIncludeDirectories>
|
||||
<AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalLibraryDirectories>$(OutDir);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<AdditionalDependencies>ws2_32.lib;libfiber_cpp.lib;lib_acl_cpp.lib;lib_protocol.lib;lib_acl.lib;libfiber.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS;_WINSOCK_DEPRECATED_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
<AdditionalIncludeDirectories>..\..\cpp\include;..\..\..\lib_acl_cpp\include</AdditionalIncludeDirectories>
|
||||
<AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>libfiber_cpp.lib;lib_acl_cpp.lib;lib_protocol.lib;lib_acl.lib;libfiber.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>$(OutDir);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseDll|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;FIBER_CPP_DLL;ACL_CPP_DLL;_CRT_SECURE_NO_WARNINGS;_WINSOCK_DEPRECATED_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
<AdditionalIncludeDirectories>..\..\cpp\include;..\..\..\lib_acl_cpp\include</AdditionalIncludeDirectories>
|
||||
<AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalLibraryDirectories>$(OutDir);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<AdditionalDependencies>ws2_32.lib;libfiber_cpp.lib;lib_acl_cpp.lib;lib_protocol.lib;lib_acl.lib;libfiber.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>_DEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS;_WINSOCK_DEPRECATED_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
<AdditionalIncludeDirectories>..\..\cpp\include;..\..\..\lib_acl_cpp\include</AdditionalIncludeDirectories>
|
||||
<AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalLibraryDirectories>$(OutDir);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<AdditionalDependencies>libfiber_cpp.lib;lib_acl_cpp.lib;lib_protocol.lib;lib_acl.lib;libfiber.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='DebugDll|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>_DEBUG;_WINDOWS;FIBER_CPP_DLL;ACL_CPP_DLL;_CRT_SECURE_NO_WARNINGS;_WINSOCK_DEPRECATED_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
<AdditionalIncludeDirectories>..\..\cpp\include;..\..\..\lib_acl_cpp\include</AdditionalIncludeDirectories>
|
||||
<AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>ws2_32.lib;libfiber_cpp.lib;lib_acl_cpp.lib;lib_protocol.lib;lib_acl.lib;libfiber.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>$(OutDir);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>NDEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS;_WINSOCK_DEPRECATED_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
<AdditionalIncludeDirectories>..\..\cpp\include;..\..\..\lib_acl_cpp\include</AdditionalIncludeDirectories>
|
||||
<AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalLibraryDirectories>$(OutDir);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<AdditionalDependencies>libfiber_cpp.lib;lib_acl_cpp.lib;lib_protocol.lib;lib_acl.lib;libfiber.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseDll|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>NDEBUG;_WINDOWS;FIBER_CPP_DLL;ACL_CPP_DLL;_CRT_SECURE_NO_WARNINGS;_WINSOCK_DEPRECATED_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
<AdditionalIncludeDirectories>..\..\cpp\include;..\..\..\lib_acl_cpp\include</AdditionalIncludeDirectories>
|
||||
<AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalLibraryDirectories>$(OutDir);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<AdditionalDependencies>ws2_32.lib;libfiber_cpp.lib;lib_acl_cpp.lib;lib_protocol.lib;lib_acl.lib;libfiber.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="FiberClient.h" />
|
||||
<ClInclude Include="FiberConnect.h" />
|
||||
<ClInclude Include="FiberServer.h" />
|
||||
<ClInclude Include="framework.h" />
|
||||
<ClInclude Include="pch.h" />
|
||||
<ClInclude Include="Resource.h" />
|
||||
<ClInclude Include="SimpleWin.h" />
|
||||
<ClInclude Include="targetver.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="FiberClient.cpp" />
|
||||
<ClCompile Include="FiberConnect.cpp" />
|
||||
<ClCompile Include="FiberServer.cpp" />
|
||||
<ClCompile Include="pch.cpp">
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='DebugDll|Win32'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='DebugDll|x64'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='ReleaseDll|Win32'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='ReleaseDll|x64'">Create</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
<ClCompile Include="SimpleWin.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="SimpleWin.rc" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Image Include="SimpleWin.ico" />
|
||||
<Image Include="small.ico" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
73
lib_fiber/samples-gui/SimpleWin/SimpleWin.vcxproj.filters
Normal file
73
lib_fiber/samples-gui/SimpleWin/SimpleWin.vcxproj.filters
Normal file
@ -0,0 +1,73 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="源文件">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="头文件">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="资源文件">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="framework.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="targetver.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Resource.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="SimpleWin.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="pch.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="FiberServer.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="FiberClient.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="FiberConnect.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="SimpleWin.cpp">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="pch.cpp">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="FiberServer.cpp">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="FiberClient.cpp">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="FiberConnect.cpp">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="SimpleWin.rc">
|
||||
<Filter>资源文件</Filter>
|
||||
</ResourceCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Image Include="small.ico">
|
||||
<Filter>资源文件</Filter>
|
||||
</Image>
|
||||
<Image Include="SimpleWin.ico">
|
||||
<Filter>资源文件</Filter>
|
||||
</Image>
|
||||
</ItemGroup>
|
||||
</Project>
|
11
lib_fiber/samples-gui/SimpleWin/framework.h
Normal file
11
lib_fiber/samples-gui/SimpleWin/framework.h
Normal file
@ -0,0 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#include "targetver.h"
|
||||
#define WIN32_LEAN_AND_MEAN // 从 Windows 头文件中排除极少使用的内容
|
||||
// Windows 头文件
|
||||
#include <windows.h>
|
||||
// C 运行时头文件
|
||||
#include <stdlib.h>
|
||||
#include <malloc.h>
|
||||
#include <memory.h>
|
||||
#include <tchar.h>
|
5
lib_fiber/samples-gui/SimpleWin/pch.cpp
Normal file
5
lib_fiber/samples-gui/SimpleWin/pch.cpp
Normal file
@ -0,0 +1,5 @@
|
||||
// pch.cpp: 与预编译标头对应的源文件
|
||||
|
||||
#include "pch.h"
|
||||
|
||||
// 当使用预编译的头时,需要使用此源文件,编译才能成功。
|
21
lib_fiber/samples-gui/SimpleWin/pch.h
Normal file
21
lib_fiber/samples-gui/SimpleWin/pch.h
Normal file
@ -0,0 +1,21 @@
|
||||
// pch.h: 这是预编译标头文件。
|
||||
// 下方列出的文件仅编译一次,提高了将来生成的生成性能。
|
||||
// 这还将影响 IntelliSense 性能,包括代码完成和许多代码浏览功能。
|
||||
// 但是,如果此处列出的文件中的任何一个在生成之间有更新,它们全部都将被重新编译。
|
||||
// 请勿在此处添加要频繁更新的文件,这将使得性能优势无效。
|
||||
|
||||
#ifndef PCH_H
|
||||
#define PCH_H
|
||||
|
||||
// 添加要在此处预编译的标头
|
||||
#include <WS2tcpip.h>
|
||||
#include <WinSock2.h>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "framework.h"
|
||||
#include "acl_cpp/lib_acl.hpp"
|
||||
#include "fiber/libfiber.hpp"
|
||||
#include "fiber/go_fiber.hpp"
|
||||
|
||||
#endif //PCH_H
|
BIN
lib_fiber/samples-gui/SimpleWin/small.ico
Normal file
BIN
lib_fiber/samples-gui/SimpleWin/small.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 45 KiB |
6
lib_fiber/samples-gui/SimpleWin/targetver.h
Normal file
6
lib_fiber/samples-gui/SimpleWin/targetver.h
Normal file
@ -0,0 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
// // 包含 SDKDDKVer.h 可定义可用的最高版本的 Windows 平台。
|
||||
// 如果希望为之前的 Windows 平台构建应用程序,在包含 SDKDDKVer.h 之前请先包含 WinSDKVer.h 并
|
||||
// 将 _WIN32_WINNT 宏设置为想要支持的平台。
|
||||
#include <SDKDDKVer.h>
|
Loading…
Reference in New Issue
Block a user