I am trying to write a pop3 fetcher module on windows. Below is the code, which receives the data from the connected socket.
It takes three parameters as input buffer, socket and data termination string.
The problem is whenever the data received on the socket is more then the DEFAULT_BUFFER it hangs.
Code:int GetCommandData (char **szBuffer, SOCKET * scl, char cmp[]) { char *ptr=NULL; int ret,idx=1; char recvBuffer[DEFAULT_BUFFER]; do{ free(*szBuffer); ret = recv (*scl, recvBuffer, DEFAULT_BUFFER - 1, 0); if (ret == SOCKET_ERROR || ret == 0) return POP3_RECV_FAILED; recvBuffer[ret] = '\0'; idx += strlen(recvBuffer); *szBuffer=malloc(idx); if (*szBuffer == NULL) return POP3_MEMORY_ALLOC_FAILED; if(ptr != NULL) { strcpy(*szBuffer,ptr); strcat(*szBuffer,recvBuffer); free(ptr); }else{ strcpy(*szBuffer,recvBuffer); } ptr = *szBuffer; }while(strcmp(&recvBuffer[strlen(recvBuffer) - strlen(cmp)],cmp) != 0); return POP3_SUCCESS; }



LinkBack URL
About LinkBacks



. I am using VC6 on Winxp sp2. config data is stored in