Description: A class for thread pool,basic usage below:
struct TSession { SOCKET socket int id } class myIocp:public CIOCP
{ public:
void OnRead(void* p, char* buf, int len)
void OnAccept(SOCKET socket)
void OnClose(void* p) }
void myIocp::OnAccept(SOCKET socket)
{ TSession*s = new TSession s->socket = socket
//here you can do something about connection session,such as find a unique id.
SetIoCompletionPort(socket, s)
// make connection socket associate with a custom structure }
void myIocp::OnRead(void* p, char* buf, int len)
{ TSession*s = (TSession*)p send(s->socket, buf, len, 0)
// return received message to client
void myIocp::OnClose(void* p) { delete p } myIoncp iocp main() { ... iocp.listen(4311)
//start listenning net port,wait for client connect.
File list (Check if you may need any files):