Analysis of the wow private server network module of the arcemu Project (I)

Source: Internet
Author: User
/* * Multiplatform Async Network Library * Copyright (c) 2007 Burlex * * SocketMgr - iocp-based SocketMgr for windows. * */#ifndef SOCKETMGR_H_WIN32#define SOCKETMGR_H_WIN32#ifdef CONFIG_USE_IOCPclass Socket;class SERVER_DECL SocketMgr : public Singleton<SocketMgr>{public:SocketMgr();~SocketMgr();ARCEMU_INLINE HANDLE GetCompletionPort() { return m_completionPort; }void SpawnWorkerThreads();void CloseAll();void ShowStatus();void AddSocket(Socket* s){socketLock.Acquire();_sockets.insert(s);++socket_count;socketLock.Release();}void RemoveSocket(Socket* s){socketLock.Acquire();_sockets.erase(s);--socket_count;socketLock.Release();}void ShutdownThreads();long threadcount;private:HANDLE m_completionPort;set<Socket*> _sockets;Mutex socketLock;Arcemu::Threading::AtomicCounter socket_count;};#define sSocketMgr SocketMgr::getSingleton()typedef void(*OperationHandler)(Socket* s, uint32 len);class SocketWorkerThread : public ThreadBase{public:bool run();};void SERVER_DECL HandleReadComplete(Socket* s, uint32 len);void SERVER_DECL HandleWriteComplete(Socket* s, uint32 len);void SERVER_DECL HandleShutdown(Socket* s, uint32 len);static OperationHandler ophandlers[NUM_SOCKET_IO_EVENTS] ={&HandleReadComplete,&HandleWriteComplete,&HandleShutdown};#endif#endif

First, go to the source code and wait for analysis...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.