Pregunta

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!

¿Fue útil?

Solución

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) ...

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top