/* Close a TCP socket from the lwip thread.  */
static void tcp_close_cb(void *ctx_p)
/* Close a TCP socket from the lwip thread.  */
static void tcp_close_cb(void *ctx_p)
{
    struct socket_t *socket_p = ctx_p;
    if (socket_p->pcb_p != NULL) {
        tcp_arg(socket_p->pcb_p, NULL);
        tcp_recv(socket_p->pcb_p, NULL);
        tcp_sent(socket_p->pcb_p, NULL);
        tcp_err(socket_p->pcb_p, NULL);
        tcp_close(socket_p->pcb_p);
    }
    resume_thrd(socket_p->input.cb.thrd_p, 0);
}