Hi all,
I am using LWIP 1.1.0 - which appears to be performing very well indeed -
using the RAW API.
What is the correct manner to return from the recv_callback when the data
may not be processed immediately?
I have experimented with several combinations of return code/whether to call
tcp_recvd with zero and/or free the pbuf - but with no luck yet?
My receive callback is summarised as follows :-
// recv callback which places incoming data into rx queue
static err_t btcp_recv_cb(void *arg, struct tcp_pcb *tpcb, struct pbuf *p,
err_t err)
{
btcp_t *h = (btcp_t *)arg;
struct pbuf *q;
int q_write_tot = 0;
ASSERT(h != NULL);
ASSERT(tpcb == h->pcb);
if(p == NULL)
{
// closed connection?
. . .
}
else
{
h->poll_retries = 0; // <- reset poll timer, due to rx activity
// check data transfer size
q_write_tot = 0;
for(q=p; q != NULL; q=q->next) q_write_tot += q->len;
// room?
if( q_write_tot < q_room(h->q_rx) )
{
// transfer data into rx queue
for(q=p; q != NULL; q=q->next)
q_write(h->q_rx, q->payload, q->len);
// indicate data has been received
tcp_recved(tpcb, q_write_tot);
pbuf_free(p);
}
else
{
// WHAT TO DO HERE???? not enough room (just at this moment in
queue!)
//tcp_recved(tpcb, 0);
pbuf_free(p);
return(ERR_OK);
}
}
return(ERR_OK);
}
Thanks!
Roger
_______________________________________________
lwip-users mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/lwip-users