Hi, if you do need to detect a particular situation on tcp_err(), then you can use the arg parameter. You are not getting the pcb because, afaik, it no longer exists; it has been removed and freed before calling the callback function; see tcp.c line 393 for example
The tcp_err() callback that will be called is the one you provided as a parameter when you set the environment for that pcb. How come you don't know what you setup ? tcp_err(mypcb, myerr); If you will reuse one tcp_err() function for many connections, you will use the arg parameter, as shown in every example application: tcp_arg(mypcb, myapplicationstructurepointer); A closure action is something like this: static void myclose(struct tcp_pcb* pcb) { state = myCLOSING; if(tcp_close(pcb) == ERR_OK){ tcp_recv(pcb, NULL); state = myCLOSED; } } You need to have a state (or equivalent) and try to do close later if the call to tcp_close() fails for low memory or whatever. If the other host sends RST, you are going to close anyway. To try later, you can use tcp_poll(): tcp_poll(mypcb, mypoll, POLL_TIME); static err_t mypoll(void *arg, struct tcp_pcb* pcb) { if(state == myCLOSING){ // Retry closing the connection myclose(pcb); } else { // Retry sending data we couldn't send before mysend(pcb); } return ERR_OK; } -- _______________________________________________ lwip-users mailing list lwip-users@nongnu.org https://lists.nongnu.org/mailman/listinfo/lwip-users