Configure the client port in esp_http_client request?

A6ESPF
Posts: 28
Joined: Tue Dec 10, 2019 12:16 pm

Configure the client port in esp_http_client request?

Postby A6ESPF » Thu Jan 12, 2023 9:05 am

Is it possible to configure the client (source) port when initializing an esp_http_client? If not, what is the default client port? There is a port field in esp_http_client_config_t struct, but it defines the port to connect to (destination port).

ESP_YJM
Posts: 300
Joined: Fri Feb 26, 2021 10:30 am

Re: Configure the client port in esp_http_client request?

Postby ESP_YJM » Thu Jan 12, 2023 9:37 am

Sorry that esp_http_client not support set source port. The source port is a random value from 49152 to 65535.

A6ESPF
Posts: 28
Joined: Tue Dec 10, 2019 12:16 pm

Re: Configure the client port in esp_http_client request?

Postby A6ESPF » Thu Jan 12, 2023 9:53 am

Is the source port changed on every esp_http_client_perform or it is set during the initialization of the client? Is there a way to get the source port somehow, so I can see which port exactly is being used?

ESP_YJM
Posts: 300
Joined: Fri Feb 26, 2021 10:30 am

Re: Configure the client port in esp_http_client request?

Postby ESP_YJM » Thu Jan 12, 2023 12:46 pm

The source port is allocated in https://github.com/espressif/esp-lwip/b ... cp.c#L1124, not in esp_http_client component, it is in low layer lwip. It is difficult to get the source port in esp_http_client layer. Because you have no API to get socket fd.

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 111 guests