/* TCP callback function if a connection (opened by tcp_connect/do_connect) has been established (or reset by the remote host). */
static err_t do_connected(void *arg, struct tcp_pcb *pcb, err_t err)
/* TCP callback function if a connection (opened by tcp_connect/do_connect) has been established (or reset by the remote host). */
static err_t do_connected(void *arg, struct tcp_pcb *pcb, err_t err)
{
    lwIP_netconn *conn = arg;
    err = ERR_OK;
    lwIP_REQUIRE_ACTION(conn, exit, err = ESP_ARG);
    conn->state = NETCONN_STATE_ESTABLISHED;
    conn->readbuf = ringbuf_new(TCP_SND_BUF);
    lwIP_REQUIRE_ACTION(conn->readbuf, exit, err = ESP_MEM);
    espconn_mbedtls_parse_internal(find_socket(conn), ERR_OK);
exit:
    return err;
}