├── .gitattributes
├── .gitignore
├── Bin
├── IOCP.exe
├── ucrtbased.dll
└── 服务器压力测试工具.exe
├── IOCP.sln
├── IOCP
├── IOCP.vcxproj
├── IOCP.vcxproj.filters
├── IOCP.vcxproj.user
├── IOCPBase.cpp
├── IOCPBase.h
├── IOCPMain.cpp
├── Release
│ └── IOCP.pch
├── stdafx.cpp
├── stdafx.h
└── targetver.h
├── LICENSE
└── README.md
/.gitattributes:
--------------------------------------------------------------------------------
1 | ###############################################################################
2 | # Set default behavior to automatically normalize line endings.
3 | ###############################################################################
4 | * text=auto
5 |
6 | ###############################################################################
7 | # Set default behavior for command prompt diff.
8 | #
9 | # This is need for earlier builds of msysgit that does not have it on by
10 | # default for csharp files.
11 | # Note: This is only used by command line
12 | ###############################################################################
13 | #*.cs diff=csharp
14 |
15 | ###############################################################################
16 | # Set the merge driver for project and solution files
17 | #
18 | # Merging from the command prompt will add diff markers to the files if there
19 | # are conflicts (Merging from VS is not affected by the settings below, in VS
20 | # the diff markers are never inserted). Diff markers may cause the following
21 | # file extensions to fail to load in VS. An alternative would be to treat
22 | # these files as binary and thus will always conflict and require user
23 | # intervention with every merge. To do so, just uncomment the entries below
24 | ###############################################################################
25 | #*.sln merge=binary
26 | #*.csproj merge=binary
27 | #*.vbproj merge=binary
28 | #*.vcxproj merge=binary
29 | #*.vcproj merge=binary
30 | #*.dbproj merge=binary
31 | #*.fsproj merge=binary
32 | #*.lsproj merge=binary
33 | #*.wixproj merge=binary
34 | #*.modelproj merge=binary
35 | #*.sqlproj merge=binary
36 | #*.wwaproj merge=binary
37 |
38 | ###############################################################################
39 | # behavior for image files
40 | #
41 | # image files are treated as binary by default.
42 | ###############################################################################
43 | #*.jpg binary
44 | #*.png binary
45 | #*.gif binary
46 |
47 | ###############################################################################
48 | # diff behavior for common document formats
49 | #
50 | # Convert binary document formats to text before diffing them. This feature
51 | # is only available from the command line. Turn it on by uncommenting the
52 | # entries below.
53 | ###############################################################################
54 | #*.doc diff=astextplain
55 | #*.DOC diff=astextplain
56 | #*.docx diff=astextplain
57 | #*.DOCX diff=astextplain
58 | #*.dot diff=astextplain
59 | #*.DOT diff=astextplain
60 | #*.pdf diff=astextplain
61 | #*.PDF diff=astextplain
62 | #*.rtf diff=astextplain
63 | #*.RTF diff=astextplain
64 |
65 | *.sh text eol=lf
66 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Compiled Object files
2 | *.slo
3 | *.lo
4 | *.o
5 | *.pdb
6 | *.exp
7 | *.idb
8 | *.ipdb
9 | *.iobj
10 | *.ilk
11 | *.obj
12 | *.log
13 | *.tlog
14 | *.cki
15 | *.exe.config
16 |
17 | # Compiled Dynamic libraries
18 | #*.so
19 | #*.dylib
20 |
21 | # Compiled Static libraries
22 | #*.lai
23 | #*.la
24 | #*.a
25 |
26 | # Intermediate directorys
27 | Static/
28 | static/
29 | Debug/
30 | debug/
31 | !Windows/Common/Src/Debug/
32 | !Windows/Common/Src/debug/
33 | Obj/
34 | obj/
35 | tlog/
36 | log/
37 | readme/
38 |
39 | # IDE Internal Files
40 | *.xml
41 | *.layout
42 | *.sdf
43 | *.VC.db
44 | *.opendb
45 | *.aps
46 | *.swp
47 | *.suo
48 | .vs/
49 |
50 | # include directory symbolic link files
51 | Linux/lib/**/*.so.*
52 |
--------------------------------------------------------------------------------
/Bin/IOCP.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TTGuoying/IOCPServer/fbea80718d99c8d67d89c6e5198aae2628daf65e/Bin/IOCP.exe
--------------------------------------------------------------------------------
/Bin/ucrtbased.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TTGuoying/IOCPServer/fbea80718d99c8d67d89c6e5198aae2628daf65e/Bin/ucrtbased.dll
--------------------------------------------------------------------------------
/Bin/服务器压力测试工具.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TTGuoying/IOCPServer/fbea80718d99c8d67d89c6e5198aae2628daf65e/Bin/服务器压力测试工具.exe
--------------------------------------------------------------------------------
/IOCP.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 15
4 | VisualStudioVersion = 15.0.27130.2010
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "IOCP", "IOCP\IOCP.vcxproj", "{14EFF15D-07B3-47FB-BBA2-2CA68D43B1B4}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|x64 = Debug|x64
11 | Debug|x86 = Debug|x86
12 | Release|x64 = Release|x64
13 | Release|x86 = Release|x86
14 | EndGlobalSection
15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
16 | {14EFF15D-07B3-47FB-BBA2-2CA68D43B1B4}.Debug|x64.ActiveCfg = Debug|x64
17 | {14EFF15D-07B3-47FB-BBA2-2CA68D43B1B4}.Debug|x64.Build.0 = Debug|x64
18 | {14EFF15D-07B3-47FB-BBA2-2CA68D43B1B4}.Debug|x86.ActiveCfg = Debug|Win32
19 | {14EFF15D-07B3-47FB-BBA2-2CA68D43B1B4}.Debug|x86.Build.0 = Debug|Win32
20 | {14EFF15D-07B3-47FB-BBA2-2CA68D43B1B4}.Release|x64.ActiveCfg = Release|x64
21 | {14EFF15D-07B3-47FB-BBA2-2CA68D43B1B4}.Release|x64.Build.0 = Release|x64
22 | {14EFF15D-07B3-47FB-BBA2-2CA68D43B1B4}.Release|x86.ActiveCfg = Release|Win32
23 | {14EFF15D-07B3-47FB-BBA2-2CA68D43B1B4}.Release|x86.Build.0 = Release|Win32
24 | EndGlobalSection
25 | GlobalSection(SolutionProperties) = preSolution
26 | HideSolutionNode = FALSE
27 | EndGlobalSection
28 | GlobalSection(ExtensibilityGlobals) = postSolution
29 | SolutionGuid = {1FABD0A4-D24D-4D74-9D28-00FB3E46C68F}
30 | EndGlobalSection
31 | EndGlobal
32 |
--------------------------------------------------------------------------------
/IOCP/IOCP.vcxproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | Win32
7 |
8 |
9 | Release
10 | Win32
11 |
12 |
13 | Debug
14 | x64
15 |
16 |
17 | Release
18 | x64
19 |
20 |
21 |
22 | 15.0
23 | {14EFF15D-07B3-47FB-BBA2-2CA68D43B1B4}
24 | Win32Proj
25 | IOCP
26 | 10.0.16299.0
27 |
28 |
29 |
30 | Application
31 | true
32 | v141
33 | Unicode
34 |
35 |
36 | Application
37 | false
38 | v141
39 | true
40 | Unicode
41 |
42 |
43 | Application
44 | true
45 | v141
46 | Unicode
47 |
48 |
49 | Application
50 | false
51 | v141
52 | true
53 | Unicode
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 | true
75 |
76 |
77 | true
78 |
79 |
80 | false
81 |
82 |
83 | false
84 |
85 |
86 |
87 | Use
88 | Level3
89 | Disabled
90 | true
91 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
92 | true
93 |
94 |
95 | Console
96 | true
97 |
98 |
99 |
100 |
101 | Use
102 | Level3
103 | Disabled
104 | true
105 | _DEBUG;_CONSOLE;%(PreprocessorDefinitions)
106 | true
107 |
108 |
109 | Console
110 | true
111 |
112 |
113 |
114 |
115 | Use
116 | Level3
117 | MaxSpeed
118 | true
119 | true
120 | true
121 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
122 | true
123 |
124 |
125 | Console
126 | true
127 | true
128 | true
129 |
130 |
131 |
132 |
133 | Use
134 | Level3
135 | MaxSpeed
136 | true
137 | true
138 | true
139 | NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
140 | true
141 |
142 |
143 | Console
144 | true
145 | true
146 | true
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 | Create
159 | Create
160 | Create
161 | Create
162 |
163 |
164 |
165 |
166 |
167 |
--------------------------------------------------------------------------------
/IOCP/IOCP.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | 头文件
20 |
21 |
22 | 头文件
23 |
24 |
25 | 头文件
26 |
27 |
28 |
29 |
30 | 源文件
31 |
32 |
33 | 源文件
34 |
35 |
36 | 源文件
37 |
38 |
39 |
--------------------------------------------------------------------------------
/IOCP/IOCP.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/IOCP/IOCPBase.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TTGuoying/IOCPServer/fbea80718d99c8d67d89c6e5198aae2628daf65e/IOCP/IOCPBase.cpp
--------------------------------------------------------------------------------
/IOCP/IOCPBase.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TTGuoying/IOCPServer/fbea80718d99c8d67d89c6e5198aae2628daf65e/IOCP/IOCPBase.h
--------------------------------------------------------------------------------
/IOCP/IOCPMain.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TTGuoying/IOCPServer/fbea80718d99c8d67d89c6e5198aae2628daf65e/IOCP/IOCPMain.cpp
--------------------------------------------------------------------------------
/IOCP/Release/IOCP.pch:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TTGuoying/IOCPServer/fbea80718d99c8d67d89c6e5198aae2628daf65e/IOCP/Release/IOCP.pch
--------------------------------------------------------------------------------
/IOCP/stdafx.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TTGuoying/IOCPServer/fbea80718d99c8d67d89c6e5198aae2628daf65e/IOCP/stdafx.cpp
--------------------------------------------------------------------------------
/IOCP/stdafx.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TTGuoying/IOCPServer/fbea80718d99c8d67d89c6e5198aae2628daf65e/IOCP/stdafx.h
--------------------------------------------------------------------------------
/IOCP/targetver.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TTGuoying/IOCPServer/fbea80718d99c8d67d89c6e5198aae2628daf65e/IOCP/targetver.h
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2018 TanGuoying
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # IOCPServer
2 | A IOCP Server Class on Windows!
3 |
4 |
5 | 本类配套文章:http://www.cnblogs.com/tanguoying/p/8439701.html
6 |
7 |
8 | 一个基于完成端口网络服务类,自带缓存池和心跳包监测!
9 |
10 | * 这个类IOCP是本代码的核心类,用于说明WinSock服务器端编程模型中的完成端口(IOCP)的使用方法
11 |
12 | * 其中的IOContext类是封装了用于每一个重叠操作的参数
13 |
14 | * 具体说明了服务器端建立完成端口、建立工作者线程、投递Recv请求、投递Accept请求的方法,所有的客户端连入的Socket都需要绑定到IOCP上,所有从客户端发来的数据,都会调用回调函数。
15 |
16 | * 用法:派生一个子类,重载回调函数
17 |
18 | Author: TTGuoying
19 |
20 | Date: 2018/02/07 16:22
21 |
22 |
23 | 开发工具 :VS2017
24 |
--------------------------------------------------------------------------------