perror("recv") tells me "Recv: no error" even though recv teturned -1.
Mt code is huge, and i don't know what part tp post. So, until i hear otherwise i am going to post my recvBlock code, and one of the contexts in which it is called.
Code:
...
int recvBlock(SOCKET client, char reply[], unsigned int flags = 0){
int ret;
if ((ret=recv(client, reply, (sizeof(reply)*256)-1, 0)) == -1) {
cout << "Recv() returned: " << ret << endl; // DEBUG
cout << "Recv() recieved: " << reply << endl; // DEBUG
perror("recv");
}
return ret;
}
...
Code:
...
char queryname[200];
int queryport;
SOCKET query;
struct hostinfo queryhost;
char buffer[1024];
memset(buffer, '\0', sizeof(buffer));
...
cin >> queryname;
queryhost = remote_host_info(queryname);
...
cin >> queryport;
query = openSocket(queryhost.ip[0],queryport);
...
sendLine(query, "GET / HTTP/1.1\n");
sendLine(query, "Accept: text/html, text/plain, */*\r\n");
sendLine(query, "Accept-Encoding: gzip, deflate\r\n");
sendLine(query, "Accept-Language: en-us\r\n");
sendLine(query, "Host: ");
sendLine(query, queryhost.name);//toUpper(queryhost.name));
sendLine(query, "\r\n\r\n");
while (recvBlock(query, buffer) == -1){
cout << buffer;
}
...