To whom it concerns:
Around line 524 of core/tcp.c, in tcp_listen_with_backlog(struct tcp_pcb *pcb, u8_t backlog):
LWIP_ERROR("tcp_listen: pcb already connected", pcb->state == CLOSED, return NULL);
/* already listening? */
if (pcb->state == LISTEN) {
return pcb;
}
A pcb->state == LISTEN never makes it past the LWIP_ERROR. Put the check for the LISTEN state above the LWIP_ERROR.
I am surprised anyone gets tcp_listen() to work at all for the raw API with this bug.
Cheers,
Joe Gorse