I am trying to read data from an HTTP server asynchronously, and trying to respond to FD_READ notifications properly. I made code to respond by doing WSAIoctl + FIONREAD to determine the data left in the buffer, and then allocated memory for it, and read from the buffer. Here is my code in response to an FD_READ
The first FD_READ notifications results in WSARecv failing with error 10045 - Operation not supportedCode:DWORD bytesOutput; DWORD bytesRecvd; DWORD flags; WSABUF wsaBuffer; int ret; char * buf; unsigned long toBeRead; ret = ::WSAIoctl (wParam, FIONREAD, 0, 0, &toBeRead, sizeof toBeRead, &bytesOutput, 0, 0); if(ret != SOCKET_ERROR && bytesOutput == sizeof toBeRead) { wsaBuffer.buf = new char[toBeRead + 1]; wsaBuffer.len = toBeRead; ret = ::WSARecv (wParam, &wsaBuffer, 1, &bytesRecvd, &flags, 0, 0); if(ret == SOCKET_ERROR) { ErrorMessage (_T("WSARecv: %d"), ::WSAGetLastError()); } wsaBuffer.buf[bytesRecvd] = 0; }
In addition, I get an exception (don't know if it matters)Originally Posted by MSDN
First-chance exception at 0x00401407 in Dialog Testing - Modal + Icon.exe: 0xC0000005: Access violation writing location 0x00dfee60.
Unhandled exception at 0x00401407 in Dialog Testing - Modal + Icon.exe: 0xC0000005: Access violation writing location 0x00dfee60.



LinkBack URL
About LinkBacks



) behavior.