ServerSockHandler.h
上传用户:tt_chan
上传日期:2009-12-03
资源大小:4523k
文件大小:1k
源码类别:

模拟服务器

开发平台:

Visual C++

  1. #ifndef _DEFAULT_SOCKET_HANDLER
  2. #define _DEFAULT_SOCKET_HANDLER
  3. #define DATA_BUFSIZE 8192
  4. enum _OVERLAPPED_FLAG
  5. {
  6. OVERLAPPED_RECV,
  7. OVERLAPPED_SEND,
  8. } OVERLAPPED_FLAG;
  9. typedef struct tag_TCOMPLETIONPORT
  10. {
  11.    OVERLAPPED Overlapped;
  12.    WSABUF DataBuf;
  13.    CHAR Buffer[DATA_BUFSIZE];
  14.    INT nOvFlag;
  15. } _TCOMPLETIONPORT, * _LPTCOMPLETIONPORT;
  16. typedef struct tag_TOVERLAPPEDEX
  17. {
  18.    CHAR Buffer[DATA_BUFSIZE];
  19.    WSABUF DataBuf;
  20.    SOCKET Socket;
  21.    WSAOVERLAPPED Overlapped;
  22.    DWORD BytesSEND;
  23.    DWORD BytesRECV;
  24.    INT nOvFlag;
  25. } _TOVERLAPPEDEX, * _LPTOVERLAPPEDEX;
  26. BOOL InitServerSocket(SOCKET &s, SOCKADDR_IN* addr, UINT nMsgID, int nPort, long lEvent = 2);
  27. BOOL ConnectToServer(SOCKET &s, SOCKADDR_IN* addr, UINT nMsgID, LPCTSTR lpServerIP, DWORD dwIP, int nPort, long lEvent);
  28. BOOL ClearSocket(SOCKET &s);
  29. BOOL CheckAvailableIOCP();
  30. INT  CreateIOCPWorkerThread(HANDLE hCP, LPDWORD lpdwThreadID, LPTHREAD_START_ROUTINE WorkerThreadFunc);
  31. BOOL InitThread(LPTHREAD_START_ROUTINE lpRoutine);
  32. BOOL CheckSocketError(LPARAM lParam);
  33. #endif