Hello Daniel,
I would like to mention that I am working with cloud based server(project specific), so i haven't done any server implementation.
Attached is the http client code with request and response Log.
I have few more questions regarding the recv() function behavior:
1. recv() returns value '0' for initial few seconds and later it returns the actual response content length. I added socket option 'OPT_RECEIVE_TIMEOUT' with value = 10000.
Do i need to program any other socket options as well?
To come over this issue, I added recv() function in while loop till the returned value is '0'.
2. After reading response for 1st time, if i try to read the response again, I am getting return value(tmpres) = '-1' and error code as 0x1638 (i.e. connection closing), but I am expecting to get value = '0' (i.e. no more data to be read). Why is it so?
(Below is the snippet of recv() function)
----
memset(recvBuf, 0, sizeof(recvBuf) );
while ((tmpres = recv(sockets.sock4, recvBuf, sizeof(recvBuf), 0)) == 0);
do
{
numBytes += tmpres;
recvBuf[tmpres] = 0; /* for test assuming receiving a html page, this can be printed */
printf("%s\n",recvBuf);
printf("Packet received of %d Bytes Total Bytes Received %d\n",tmpres,numBytes);
tmpres = recv(sockets.sock4, recvBuf, sizeof(recvBuf), 0);
}while(tmpres > 0);
----
Please let me know, how can I overcome these issues..
Thanks,
Priya