Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

59 lines
1.8 KiB

  1. /************************************************************************************************
  2. Copyright (c) 2001 Microsoft Corporation
  3. File Name: SockPool.hxx
  4. Abstract: Defines the SocketPool Class
  5. Notes:
  6. History: 08/01/2001 Created by Hao Yu (haoyu)
  7. ************************************************************************************************/
  8. #ifndef __POP3_SOCKET_POOL__
  9. #define __POP3_SOCKET_POOL__
  10. #include <IOContext.h>
  11. #include <Ws2tcpip.h>
  12. class CSocketPool
  13. {
  14. public:
  15. CSocketPool();
  16. ~CSocketPool();
  17. BOOL Initialize(DWORD dwMax, DWORD dwMin, DWORD dwThreshold, u_short usPort, int iBackLog);
  18. BOOL Uninitialize();
  19. BOOL IsMoreSocketsNeeded();
  20. BOOL MaintainSocketCount();
  21. BOOL AddSockets();
  22. void DecrementFreeSocketCount();
  23. void DecrementTotalSocketCount();
  24. BOOL ReuseIOContext(PIO_CONTEXT pIoContext);
  25. BOOL IsMaxSocketUsed();
  26. private:
  27. //Data Members
  28. SOCKET m_sMainSocket;
  29. IO_CONTEXT m_stMainIOContext;
  30. LONG m_lMaxSocketCount;
  31. LONG m_lMinSocketCount;
  32. LONG m_lThreshold;
  33. LONG m_lTotalSocketCount;
  34. LONG m_lFreeSocketCount;
  35. CRITICAL_SECTION m_csInitGuard;
  36. BOOL m_bInit;
  37. int m_iBackLog;
  38. LONG m_lAddThreadToken;
  39. int m_iSocketFamily; //For supporting IPv4 & IPv6
  40. int m_iSocketType;
  41. int m_iSocketProtocol;
  42. //Functions
  43. BOOL CreateMainSocket(u_short usPort);
  44. BOOL AddSocketsP(DWORD dwNumOfSocket);
  45. BOOL CreateAcceptSocket(PIO_CONTEXT pIoContext);
  46. };
  47. typedef CSocketPool *PCSocketPool;
  48. #endif //__POP3_SOCKET_POOL__