Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. BindIoCompletionCallback in a class, problem with LPOVERLAPPED_COMPLETION_ROUTINE

BindIoCompletionCallback in a class, problem with LPOVERLAPPED_COMPLETION_ROUTINE

Scheduled Pinned Locked Moved C / C++ / MFC
helpc++regex
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    jgauffin
    wrote on last edited by
    #1

    Hello I want to create a baseclass for socket servers that use io completion ports. But I cant manage to pass a class function to BindIoCompletionCallback. BOOL BindIoCompletionCallback( HANDLE FileHandle, LPOVERLAPPED_COMPLETION_ROUTINE Function, ULONG Flags ); I call it with: BindIoCompletionCallback((HANDLE)m_sdListen, DoneIO, 0); My class looks like: class IocpServer { public: IocpServer(void); ~IocpServer(void); void CreateListenSocket(int ListenPort); void Start(void); HANDLE GetDieEvent(); void CALLBACK DoneIO(DWORD dwErrorCode, DWORD dwNumberOfBytesTransferred, LPOVERLAPPED lpOverlapped); private: SOCKET m_sdListen; DWORD m_dwThreadCount; HANDLE m_hIOCP; UINT m_iListenPort; HANDLE m_hDieEvent; }; I get this error: d:\projects\cpp\Datatal\HvdServer\IocpServer.cpp(24) : error C2664: 'BindIoCompletionCallback' : cannot convert parameter 2 from 'void (DWORD,DWORD,LPOVERLAPPED)' to 'LPOVERLAPPED_COMPLETION_ROUTINE' None of the functions with this name in scope match the target type

    G 1 Reply Last reply
    0
    • J jgauffin

      Hello I want to create a baseclass for socket servers that use io completion ports. But I cant manage to pass a class function to BindIoCompletionCallback. BOOL BindIoCompletionCallback( HANDLE FileHandle, LPOVERLAPPED_COMPLETION_ROUTINE Function, ULONG Flags ); I call it with: BindIoCompletionCallback((HANDLE)m_sdListen, DoneIO, 0); My class looks like: class IocpServer { public: IocpServer(void); ~IocpServer(void); void CreateListenSocket(int ListenPort); void Start(void); HANDLE GetDieEvent(); void CALLBACK DoneIO(DWORD dwErrorCode, DWORD dwNumberOfBytesTransferred, LPOVERLAPPED lpOverlapped); private: SOCKET m_sdListen; DWORD m_dwThreadCount; HANDLE m_hIOCP; UINT m_iListenPort; HANDLE m_hDieEvent; }; I get this error: d:\projects\cpp\Datatal\HvdServer\IocpServer.cpp(24) : error C2664: 'BindIoCompletionCallback' : cannot convert parameter 2 from 'void (DWORD,DWORD,LPOVERLAPPED)' to 'LPOVERLAPPED_COMPLETION_ROUTINE' None of the functions with this name in scope match the target type

      G Offline
      G Offline
      geo_m
      wrote on last edited by
      #2

      I guess, that if the DoneIO is the member of your class, you can't do it in that way. The DoneIO can be a member only if it is a static member, then you can use it for callbacks. Normal class members have calling convention _thiscall, which you cannot achieve in callbacks. So for you it will help to make that function static (static members do not have the first hidden parameter - this).

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups