after some search I finally found a way to set server port at setup:
add
void begin(uint16_t port);
add
void ESP8266WebServer::begin(uint16_t port) {
_currentStatus = HC_NONE;
_server.begin(port);
if(!_headerKeysCount)
collectHeaders(0, 0);
}
add
void begin(uint16_t port);
add
void WiFiServer::begin(uint16_t port) {
close();
_port = port;
err_t err;
tcp_pcb* pcb = tcp_new();
if (!pcb)
return;
ip_addr_t local_addr;
local_addr.addr = (uint32_t) _addr;
pcb->so_options |= SOF_REUSEADDR;
err = tcp_bind(pcb, &local_addr, _port);
if (err != ERR_OK) {
tcp_close(pcb);
return;
}
tcp_pcb* listen_pcb = tcp_listen(pcb);
if (!listen_pcb) {
tcp_close(pcb);
return;
}
_pcb = listen_pcb;
tcp_accept(listen_pcb, &WiFiServer::_s_accept);
tcp_arg(listen_pcb, (void*) this);
}
change normal server begin to server.begin(8080); or another port.
if you use captive portal and isIP function pay attention on server.hostheader() now you have to include the port, my I changed to
boolean isIp(String str) {
for (int i = 0; i < str.length(); i++) {
int c = str.charAt(i);
if (c != '.' && (c < '0' || c > '9') && c != ':') {
return false;
}
}
return true;
}
sorry about the bad english, its no my native laguage.
credits to:LuchoBecerra