Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/http/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用lwip的HTTP GET中途停止_Http_Http Get_Lwip - Fatal编程技术网

使用lwip的HTTP GET中途停止

使用lwip的HTTP GET中途停止,http,http-get,lwip,Http,Http Get,Lwip,我使用lwip作为客户端,从服务器进行HTTP GET。我希望收到的文件大约是75kB。我正确地获得了第一个~9kB,但是没有更多的数据到达。到达堆栈的每个数据包都被正确地确认 简而言之,我使用netconn接口和以下命令。在几个数据包到达之前,没有人会给出错误,在此之后,netconn_recv开始给出超时,直到大约15分钟后,服务器发送一个数据包来关闭连接(这告诉我,至少在某种意义上,连接仍在工作) #定义HTTP_GET_模板“GET/%s HTTP/1.0\r\n主机:%s\r\n\r\

我使用lwip作为客户端,从服务器进行HTTP GET。我希望收到的文件大约是75kB。我正确地获得了第一个~9kB,但是没有更多的数据到达。到达堆栈的每个数据包都被正确地确认

简而言之,我使用netconn接口和以下命令。在几个数据包到达之前,没有人会给出错误,在此之后,netconn_recv开始给出超时,直到大约15分钟后,服务器发送一个数据包来关闭连接(这告诉我,至少在某种意义上,连接仍在工作)

#定义HTTP_GET_模板“GET/%s HTTP/1.0\r\n主机:%s\r\n\r\n”
地址=
#define HTTP_GET_TEMPLATE "GET /%s HTTP/1.0\r\nHost: %s\r\n\r\n"

addr = <the ip address I'm talking to>
location = <location of the filename on the host>
host = <hostname>

upg = netconn_new(NETCONN_TCP);
netconn_set_recvtimeout(upg, 30000);
err = netconn_bind(upg, IP_ADDR_ANY, 0);
err = netconn_connect(upg, &addr, 80);
sprintf(request, HTTP_GET_TEMPLATE, location, host);
siRc = netconn_write(upg, request, (strlen(request)+1)*sizeof(char), NETCONN_COPY);
while (true)
{
    err = netconn_recv(upg, &netbuf);
    if (ERR_IS_FATAL(err))
    {
        break;
    }
    if (err == ERR_OK)
    {
        do
        {
            err = netbuf_data(netbuf, &data, &len);
            < handle the data in "data">
        } while (netbuf_next(netbuf) >= 0);

        netbuf_delete(netbuf);
    }
}