سؤال

My application can simultaneously send and receive data from the client using WSASend and WSARecv. So, How can distinguish which operation was completed in IOCP processing thread (send or receive)?

BOOL bReturn = GetQueuedCompletionStatus(srv.m_hCompPort, &dwBytesTransfered, (LPDWORD)&lpContext, &pOverlapped, INFINITE);

I thought I can use OVERLAPED structure for this purpose, but I can't. Any idea?

Thank You!

هل كانت مفيدة؟

المحلول

Solution is very simple:

struct iOverlaped : public OVERLAPPED{
    enum Type {
        Send,
        Receive
    };
    iOverlaped(Type type_ ) {
        ZeroMemory(this, sizeof(iOverlaped));
        type = type_;
    }

    Type type;
};

And for every connection we have to create two overlapped instances (one per each operation type) ...

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top