Hello, I want to loop through a message board and read HTML of the topics using Winsock. On the first iteration of the loop it works flawlessly - I can receive the response with no problems, however, on the next iterations recv() returns 0 immediately without even waiting for the data to arrive. Here's my code:
errno is 0 after each call to recv(). What could be the fault? Thanks.Code:for(set<string>::iterator it = topicIDs.begin(); it != topicIDs.end(); it++) { int iResult = 0; string sendbuf = "GET /phpBB3/viewtopic.php?f=7&t=" + *it + " HTTP/1.1\r\n" "Host: <valid host>\r\n" "\r\n"; //a valid request is generated here iResult = send(client, sendbuf.c_str(), sendbuf.length(), 0); if(iResult == SOCKET_ERROR) { Error("send failed"); } //nothing wrong with this send(), it returns the number of bytes char recvbuf[512]; memset(recvbuf, 0, 512); do { iResult = recv(client, recvbuf, 512, 0); if ( iResult > 0 ) { HTML += (recvbuf); //HTML is an std::string object } else if ( iResult == 0 ) Error("Connection closed, recv done\n"); //returns 0 immediately on the second iteration of the loop else Error("recv failed with error: "); } while( iResult > 0 ); Process(HTML); //random processing of the code }



LinkBack URL
About LinkBacks



