Usually the driver asks for PBUF_POOL, while TCP takes from PBUF_RAM. Whatever you free in rx callbacks shouldn't mess with tx since they use different areas. PBUF_POOL is allocated as memp_malloc(MEMP_PBUF_POOL), which takes memory from a pool of pbufs defined in the MEMP_ are of lwipopts PBUF_RAM is allocated as mem_malloc(), which takes memory from a heap of size MEM_SIZE, which I see rather small (I use 4K), but your data is small too. ... unless you set otherwise in your lwipopts; but I didn't see that. Did you ?
My tcp_recv() callback is something like: if ((p == NULL) || (err != ERR_OK)){ printf("Connection closed by remote end\n"); if(tcp_close(pcb) == ERR_OK){ tcp_recv(pcb, NULL); } /* otherwise retry closure at the poll callback but this has been simplified in 2.0 and I'm too lazy to update */ return ERR_OK; } pbuf_copy_partial(p, somewhere, p->tot_len, 0); tcp_recved(pcb, p->tot_len); pbuf_free(p); return ERR_OK; You have to return ERR_OK on closure, not the err parameter http://www.nongnu.org/lwip/2_0_x/tcp_8h.html#a780cfac08b02c66948ab94ea974202e8 The tcp_sent() callback is used to resume sending when you could not fit all your data on a single call to tcp_write. Then you wait for the stack to tell you when its done and just in case you set up a poll callback to call you later. You return ERR_OK and do nothing. IIRC you can skip defining a callback and the stack will stay happy. _______________________________________________ lwip-users mailing list lwip-users@nongnu.org https://lists.nongnu.org/mailman/listinfo/lwip-users