int CUdpSocket::PostRequestData(int i) { int err=0; // Error code ULONG ulRevBytes; // Number of bytes received ULONG flags=0; // Receive flags // We use completion routing, so event field can be utilized for additional parameter m_overlap.hEvent = (HANDLE)(&m_overlapBuf[i]); err = WSARecvFrom (m_udp_socket, &m_wsaBuf[i], 1, &ulRevBytes, &flags, (PSOCKADDR)&m_fromAddr, &m_fromAddrLen, &m_overlap, RcvCompletion ); if((err==0) || ((err=WSAGetLastError ())==WSA_IO_PENDING)) { return 0; } return err; }
If lpCompletionRoutine is not NULL, the hEvent parameter is ignored and can be used by the application to pass context information to the completion routine. A caller that passes a non-NULLlpCompletionRoutine and later calls WSAGetOverlappedResult for the same overlapped I/O request may not set the fWait parameter for that invocation of WSAGetOverlappedResult to TRUE. In this case the usage of the hEvent parameter is undefined, and attempting to wait on the hEvent parameter would produce unpredictable results.The completion routine follows the same rules as stipulated for Windows file I/O completion routines. The completion routine will not be invoked until the thread is in an alertable wait state such as can occur when the function WSAWaitForMultipleEvents with the fAlertable parameter set to TRUE is invoked.The transport providers allow an application to invoke send and receive operations from within the context of the socket I/O completion routine, and guarantee that, for a given socket, I/O completion routines will not be nested. This permits time-sensitive data transmissions to occur entirely within a preemptive context.
----------------------------
阻塞了??
int CUdpSocket::PostRequestData(int i)
{
int err=0; // Error code
ULONG ulRevBytes; // Number of bytes received
ULONG flags=0; // Receive flags
// We use completion routing, so event field can be utilized for additional parameter
m_overlap.hEvent = (HANDLE)(&m_overlapBuf[i]);
err = WSARecvFrom (m_udp_socket,
&m_wsaBuf[i],
1,
&ulRevBytes,
&flags,
(PSOCKADDR)&m_fromAddr,
&m_fromAddrLen,
&m_overlap,
RcvCompletion
);
if((err==0) || ((err=WSAGetLastError ())==WSA_IO_PENDING))
{
return 0;
}
return err;
}