我正在开发一个需要解析Chunked类型HTTP传输的客户端.我试着用下面的方法弄清楚错误,并且如果有人能够更快地捕捉到我的错误,我会很感激.总结一下这个问题:似乎客户端没有收到所有的块,从而搞砸了剩下的进程.提前致谢!
while(cflag){
pfile_chunk = malloc(CHUNK_SIZE+1);
memset(pfile_chunk, 0, CHUNK_SIZE);
cPtr = pfile_chunk;
cPtr2 = NULL;
k=0;
while(*(cPtr-1) != '\n'){
k++;
recv(sock, cPtr, 1, 0);
cPtr = pfile_chunk+k;
}
cPtr2 = strchr(pfile_chunk, '\r');
*cPtr2 = '\0';
sscanf(pfile_chunk, "%x", &l);
if(l == 0)
break;
printf("\nServer wants to deliver %ld bytes.\n", l);
pfile_chunk = realloc(pfile_chunk, l+1);
memset(pfile_chunk, 0, l);
recv(sock, pfile_chunk, l, 0);
fputs(pfile_chunk, f);
printf("GOT THIS, SIZE %ld:\n%s\n", strlen(pfile_chunk), pfile_chunk);
//get next \r\n bytes.
recv(sock, NULL, 2, 0);
}
Run Code Online (Sandbox Code Playgroud) 我有兴趣在iPhone上的私人应用程序中发送彩信.我需要的很多信息都是专有的,因此我无法在任何地方找到它.基本上,我正在寻找构建CTMessage并将其编码为MMS的正确方法,然后通过其中一个重载的sendMMS函数发送它.提前致谢.