Skip to content

client local port is zeroed because _pcb is set to null before onData and onDisconnect callbacks #49

@mathieucarbou

Description

@mathieucarbou
          **Everything good! Works without issues in my app.**

The only thing I noticed while testing some examples is that the client _pcb->local_port gets zeroed before the client disconnect callback gets called. Maybe it's fine. I've seen this behavior in the main branch also.

I (5856) AsyncTCP: ** data received by client: 62214: len=202
I (5856) AsyncTCP: ** data received by client: 62214: len=1440
I (5866) AsyncTCP: ** data received by client: 0: len=117 // <- See here
I (5866) AsyncTCP: ** client has been disconnected: 0 // <- See here

This is the code:

client->onConnect([](void *arg, AsyncClient *client)
    {
        ESP_LOGI("AsyncTCP", "** client has been connected: %" PRIu16 "\n", client->localPort());

        client->onDisconnect([](void *arg, AsyncClient *client) {
            ESP_LOGI("AsyncTCP", "** client has been disconnected: %" PRIu16 "\n", client->localPort());
            client->close(true);
            delete client;
        });

        client->onData([](void *arg, AsyncClient *client, void *data, size_t len) {
            ESP_LOGI("AsyncTCP", "** data received by client: %" PRIu16 ": len=%u\n", client->localPort(), len);
        });

        client->write("GET /README.md HTTP/1.1\r\nHost: 192.168.2.33 \r\nUser-Agent: ESP\r\nConnection: close\r\n\r\n");
    });

Originally posted by @gnalbandian in #48 (comment)

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions