Skip to content

fix #1167 WiFiServer stop / close #1189

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 10, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions libraries/ESP8266WebServer/src/ESP8266WebServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ ESP8266WebServer::~ESP8266WebServer() {
delete handler;
handler = next;
}
close();
}

void ESP8266WebServer::begin() {
Expand Down Expand Up @@ -173,6 +174,14 @@ void ESP8266WebServer::handleClient() {
_handleRequest();
}

void ESP8266WebServer::close() {
_server.close();
}

void ESP8266WebServer::stop() {
close();
}

void ESP8266WebServer::sendHeader(const String& name, const String& value, bool first) {
String headerLine = name;
headerLine += ": ";
Expand Down
3 changes: 3 additions & 0 deletions libraries/ESP8266WebServer/src/ESP8266WebServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ class ESP8266WebServer
void begin();
void handleClient();

void close();
void stop();

bool authenticate(const char * username, const char * password);
void requestAuthentication();

Expand Down
10 changes: 10 additions & 0 deletions libraries/ESP8266WiFi/src/WiFiServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,16 @@ uint8_t WiFiServer::status() {
return _pcb->state;
}

void WiFiServer::close() {
if (!_pcb) {
return;
}
tcp_close(_pcb);
}

void WiFiServer::stop() {
close();
}

size_t WiFiServer::write(uint8_t b) {
return write(&b, 1);
Expand Down
2 changes: 2 additions & 0 deletions libraries/ESP8266WiFi/src/WiFiServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ class WiFiServer : public Server {
virtual size_t write(uint8_t);
virtual size_t write(const uint8_t *buf, size_t size);
uint8_t status();
void close();
void stop();

using Print::write;

Expand Down