http client end of conversation

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

http client end of conversation

koszo.simon
Hi,

I have just started to use http client application in lwIP 2.1.2. I use raw
API with #define NO_SYS 1.

I could successfully download 350 KB test file by calling the following
function:

httpc_get_file(&server_addr, portnum, pst->url, conn_settings_try,
HttpClientGetFileReceive, NULL, NULL);  

The callback function looks like this:

err_t HttpClientGetFileReceive(void *arg, struct tcp_pcb* tpcb, struct pbuf
*p, err_t err) {
    if (p != NULL) {
        packet_cnt++;
        dprintf("packet_cnt: %u\n", packet_cnt);
        tcp_recved(tpcb, p->tot_len);                      
        pbuf_free(p);
    } else {
       dprintf("This is the end of the conversation\n");
    }
    return ERR_OK;
}

The dprintf function print debug messages on the serial port. I got the
counter values from 0 till 240. This fits to the number of the packets
observed in WireShark. However I haven't got the "This is the end of the
conversation" message.

How my application can notice if the tcp conversation with the http server
has been finished?

Thank you for any idea in advance:
Simon Kószó




--
Sent from: http://lwip.100.n7.nabble.com/lwip-users-f3.html

_______________________________________________
lwip-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-users
Reply | Threaded
Open this post in threaded view
|

Re: http client end of conversation

goldsimon@gmx.de
Am 24.06.2019 um 10:39 schrieb koszo.simon:

> Hi,
>
> I have just started to use http client application in lwIP 2.1.2. I use raw
> API with #define NO_SYS 1.
>
> I could successfully download 350 KB test file by calling the following
> function:
>
> httpc_get_file(&server_addr, portnum, pst->url, conn_settings_try,
> HttpClientGetFileReceive, NULL, NULL);
>
> The callback function looks like this:
>
> err_t HttpClientGetFileReceive(void *arg, struct tcp_pcb* tpcb, struct pbuf
> *p, err_t err) {
>      if (p != NULL) {
>          packet_cnt++;
>          dprintf("packet_cnt: %u\n", packet_cnt);
>          tcp_recved(tpcb, p->tot_len);
>          pbuf_free(p);
>      } else {
>         dprintf("This is the end of the conversation\n");
>      }
>      return ERR_OK;
> }
>
> The dprintf function print debug messages on the serial port. I got the
> counter values from 0 till 240. This fits to the number of the packets
> observed in WireShark. However I haven't got the "This is the end of the
> conversation" message.
>
> How my application can notice if the tcp conversation with the http server
> has been finished?

Well, this is a bit different, the client calls the 'result_fn' from the
'httpc_conntetion_t' struct when finished instead of calling the recv
function with a NULL pbuf. That might be a good idea, but it's not like
that currently.


Regards,
Simon

_______________________________________________
lwip-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-users