0

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!

4

1 回答 1

0

解决方法很简单:

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

    Type type;
};

对于每个连接,我们必须创建两个重叠的实例(每种操作类型一个)......

于 2013-06-14T02:26:04.270 回答