Memory strategy when using IOCP

I am new to Windows IOCP, I am currently rewriting the network part of our server with IOCP. I'm trying to figure out how to handle memory (Overlapped / WSABUF objects). I have a small structure that comes from OVERLAPPED and contains WSABUF and a few other fields.

I tried to save a ring buffer for these objects and reuse them, but it didn't work. I thought that when the completion routine was called, one of the objects would be passed back to me and I could mark it as available again.

When I allocate them on the heap (and store them in a vector), how can I know when it is safe to delete / reuse it?

Thanks Michael

+3
c ++ windows networking


source to share


No one has answered this question yet

Check out similar questions:

2299
When should static_cast, dynamic_cast, const_cast, and reinterpret_cast be used?
1783
C ++ 11 introduced a standardized memory model. What does it mean? And how will this affect C ++ programming?
1699
What is a smart pointer and when should I use it?
1305
When to use virtual destructors?
951
Can a local memory variable be accessed outside of its scope?
five
When using IOCP, should WSAOVERLAPPED hEvent be set to NULL, or a valid handle to the WSAEVENT object?
3
Quick design question about C ++ container classes in shared memory
3
Caching OVERLAPPED Structures Using IOCP on Windows
2
WSARecv sometimes returns an "invalid descriptor (error # 6)" for a socket associated with an IOCP port. (C ++)
1
Preventing automatic destruction of variables through dynamic memory management



All Articles
Loading...
X
Show
Funny
Dev
Pics