I am using lwIP stack (version 1.4.1) with raw API.
Is there a way to identify the right socket using protocol control block (struct pcb*
) parameter which is provided by callback functions?
My application has two sockets and I need to know which instance I am handling inside callback functions.
The first argument of the lwIP callbacks is pcb-specific and can be set by the user. For struct tcp_pcb, use the void tcp_arg(struct tcp_pcb *pcb, void *arg)
function. For struct udp_pcb, the argument is set in the call to udp_recv
.
The argument is stored in the structs, so it's also possible to access them directly.