In the past few days, I have been studying multi-threading and network socket models. I wrote these and recorded them based on Teacher Renzhai’s C++ tutorial and the API reference provided by Windows as well as some information on the Internet. Server side code. #define _CRT_SECURE_NO_WARNINGS #include <WinSock2.h> #include <list> #include <process.h> #include <iostream> #pragma […]
Tag: iocp
Windows socket I/0 model – IOCP completion port model
In Windows network programming, IOCP (Input/Output Completion Port) is a high-performance I/O model that enables applications to handle a large number of concurrent I/O operations. The IOCP model mainly handles asynchronous I/O operations through event notification and callback functions. Compared with the previously introduced models such as select, WSAAsyncSelect and WSAEventSelect, the advantage of the […]
IOCP model under windows
1 iocp echo server ————————————-ThreadPool.h——- ——————————— //The thread pool is the basis of the iocp echo server #pragma once #include <atomic> #include <process.h> #include <vector> #include <mutex> #include <WinSock2.h> #include <atlstr.h> #include <iostream> typedef int (*FUNCTYPE)(void*); class ThreadWorker { public: ThreadWorker() : func(NULL), arg(arg) {}; ThreadWorker(FUNCTYPE f, void* arg = NULL) : func(f), arg(arg) {} […]
A complete example of efficient network model IOCP under Windows
IOCP is the completion port (I/O Completion Port). Like epoll under Linux, it is a very efficient network model. epoll is to send a processable notification message when the resource is ready; IOCP is to send a completion notification message when the event is completed. The epoll model is like going to the bank to […]