How to get server IP for incoming HTTP request?
Posted: Mon Jan 22, 2024 5:34 pm
I have a webserver which is bound to 0.0.0.0 so it can respond with the ESP in both Station and Access Point mode simultaneously.
When an incoming request comes in I can see how to get the clientIP using code like this:
But how can I tell what IP the request came in on, i.e. the server IP?
I need to know if the request came from a client connected to the ESP as a AP or STA
Thanks
When an incoming request comes in I can see how to get the clientIP using code like this:
Code: Select all
int _socket = accept(serverSocketID, (struct sockaddr * )&_sockAddr, &_addrLen);
...
struct sockaddr_in *sockAddrIn = (struct sockaddr_in *)(&_sockAddr);
IPAddress clientIp(sockAddrIn->sin_addr.s_addr);
I need to know if the request came from a client connected to the ESP as a AP or STA
Thanks