Source code of Windows XP (NT5)
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.

163 lines
3.4 KiB

  1. /**********************************************************************/
  2. /** Microsoft Windows NT **/
  3. /** Copyright(c) Microsoft Corp., 1994 **/
  4. /**********************************************************************/
  5. /*
  6. cpsock.h
  7. This module contains the communication package prototypes and
  8. the implementation for TCP sockets.
  9. FILE HISTORY:
  10. Johnl 08-Aug-1994 Created.
  11. */
  12. #ifndef _CPSOCK_H_
  13. #define _CPSOCK_H_
  14. #ifdef __cplusplus
  15. extern "C" {
  16. #endif
  17. //
  18. // This is the function callback that is called when the connect thread has
  19. // accepted a new connection
  20. //
  21. typedef
  22. VOID
  23. (*PFN_ON_CONNECT)(
  24. SOCKET sNew,
  25. SOCKADDR_IN * psockaddr
  26. );
  27. //
  28. // Contains Connection Package socket information
  29. //
  30. typedef struct _CP_INFO
  31. {
  32. //
  33. // Function to be called when a new connection comes in
  34. //
  35. PFN_ON_CONNECT pfnOnConnect;
  36. //
  37. // Addressing information
  38. //
  39. SOCKADDR_IN sockaddr;
  40. //
  41. // Thread handle of connect thread. Used to synchronize shutdown
  42. //
  43. HANDLE hConnectThread;
  44. //
  45. // Critical section that should be taken when modifying any of the
  46. // following members
  47. //
  48. CRITICAL_SECTION InfoCriticalSection;
  49. //
  50. // Tells connect thread to terminate itself
  51. //
  52. BOOL fShutDown;
  53. //
  54. // Socket the connect thread listens on for incoming connections
  55. //
  56. SOCKET ListenSocket;
  57. } CP_INFO, *PCP_INFO;
  58. ////////////////////////////////////////////////////////////////////////////
  59. //
  60. // Communication Package function pointers
  61. //
  62. ////////////////////////////////////////////////////////////////////////////
  63. typedef
  64. BOOL
  65. (*PFN_CPINITIALIZE)(
  66. PCP_INFO * ppInfo,
  67. PFN_ON_CONNECT pfnOnConnect,
  68. BYTE * LocalAddress,
  69. u_short port,
  70. DWORD reserved
  71. );
  72. typedef
  73. INT
  74. (*PFN_CPCREATELISTENSOCKET)(
  75. PCP_INFO pcpInfo
  76. );
  77. typedef
  78. BOOL
  79. (*PFN_CPSTARTCONNECTTHREAD)(
  80. PCP_INFO pcpInfo
  81. );
  82. typedef
  83. BOOL
  84. (*PFN_CPSTOPCONNECTTHREAD)(
  85. PCP_INFO pcpInfo
  86. );
  87. //
  88. // Forcefully closes a socket
  89. //
  90. INT ResetSocket( SOCKET s );
  91. //
  92. // Serialization for access to the CP_INFO data (used primarily during
  93. // shutdown)
  94. //
  95. #define LockCPInfo(pcpInfo) EnterCriticalSection( &(pcpInfo)->InfoCriticalSection )
  96. #define UnlockCPInfo(pcpInfo) LeaveCriticalSection( &(pcpInfo)->InfoCriticalSection )
  97. //
  98. // For now, we'll only support TCP sockets
  99. //
  100. #define CPInitialize TcpInitialize
  101. #define CPCreateListenSocket TcpCreateListenSocket
  102. #define CPStartConnectThread TcpStartConnectThread
  103. #define CPStopConnectThread TcpStopConnectThread
  104. ////////////////////////////////////////////////////////////////////////////
  105. //
  106. // TCP Sockets Communication Package prototypes
  107. //
  108. ////////////////////////////////////////////////////////////////////////////
  109. dllexp
  110. BOOL TcpInitialize( PCP_INFO * ppInfo,
  111. PFN_ON_CONNECT pfnOnConnect,
  112. BYTE * LocalAddress,
  113. u_short port,
  114. DWORD reserved );
  115. dllexp INT TcpCreateListenSocket( PCP_INFO pcpInfo );
  116. dllexp BOOL TcpStartConnectThread( PCP_INFO pcpInfo );
  117. dllexp BOOL TcpStopConnectThread( PCP_INFO pcpInfo );
  118. #ifdef __cplusplus
  119. }
  120. #endif
  121. #endif //!_CPSOCK_H_
  122.