Skip to content

Commit

Permalink
use server.accept() instead of available()
Browse files Browse the repository at this point in the history
  • Loading branch information
JAndrassy committed Dec 21, 2021
1 parent 91e2ab1 commit a96309c
Show file tree
Hide file tree
Showing 12 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions libraries/ESP8266AVRISP/src/ESP8266AVRISP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ AVRISPState_t ESP8266AVRISP::update() {
switch (_state) {
case AVRISP_STATE_IDLE: {
if (_server.hasClient()) {
_client = _server.available();
_client = _server.accept();
_client.setNoDelay(true);
AVRISP_DEBUG("client connect %s:%d", _client.remoteIP().toString().c_str(), _client.remotePort());
_client.setTimeout(100); // for getch()
Expand Down Expand Up @@ -121,7 +121,7 @@ AVRISPState_t ESP8266AVRISP::serve() {
}

inline void ESP8266AVRISP::_reject_incoming(void) {
while (_server.hasClient()) _server.available().stop();
while (_server.hasClient()) _server.accept().stop();
}

uint8_t ESP8266AVRISP::getch() {
Expand Down
2 changes: 1 addition & 1 deletion libraries/ESP8266WebServer/src/ESP8266WebServer-impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ void ESP8266WebServerTemplate<ServerType>::serveStatic(const char* uri, FS& fs,
template <typename ServerType>
void ESP8266WebServerTemplate<ServerType>::handleClient() {
if (_currentStatus == HC_NONE) {
ClientType client = _server.available();
ClientType client = _server.accept();
if (!client) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ static const char *HTTP_RES =

void loop() {
static int cnt;
BearSSL::WiFiClientSecure incoming = server.available();
BearSSL::WiFiClientSecure incoming = server.accept();
if (!incoming) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ static const char *HTTP_RES =
"</html>\r\n";

void loop() {
BearSSL::WiFiClientSecure incoming = server.available();
BearSSL::WiFiClientSecure incoming = server.accept();
if (!incoming) {
return;
}
Expand Down
2 changes: 1 addition & 1 deletion libraries/ESP8266WiFi/examples/IPv6/IPv6.ino
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ unsigned long statusTimeMs = 0;
void loop() {

if (statusServer.hasClient()) {
WiFiClient cli = statusServer.available();
WiFiClient cli = statusServer.accept();
status(cli);
}

Expand Down
2 changes: 1 addition & 1 deletion libraries/ESP8266WiFi/examples/WiFiEcho/WiFiEcho.ino
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ void loop() {

//check if there are any new clients
if (server.hasClient()) {
client = server.available();
client = server.accept();
Serial.println("New client");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ void setup() {

void loop() {
// Check if a client has connected
WiFiClient client = server.available();
WiFiClient client = server.accept();
if (!client) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,16 +130,16 @@ void loop() {
int i;
for (i = 0; i < MAX_SRV_CLIENTS; i++)
if (!serverClients[i]) { // equivalent to !serverClients[i].connected()
serverClients[i] = server.available();
serverClients[i] = server.accept();
logger->print("New client: index ");
logger->print(i);
break;
}

//no free/disconnected spot so reject
if (i == MAX_SRV_CLIENTS) {
server.available().println("busy");
// hints: server.available() is a WiFiClient with short-term scope
server.accept().println("busy");
// hints: server.accept() is a WiFiClient with short-term scope
// when out of scope, a WiFiClient will
// - flush() - all data will be sent
// - stop() - automatically too
Expand Down
4 changes: 2 additions & 2 deletions libraries/ESP8266WiFiMesh/src/ESP8266WiFiMesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,7 @@ void ESP8266WiFiMesh::acceptRequest()
if(_handler != NULL)
{
while (true) {
_client = _server.available();
_client = _server.accept();
if (!_client)
break;

Expand All @@ -647,7 +647,7 @@ void ESP8266WiFiMesh::acceptRequest()
{
////////////////////////////</DEPRECATED> TODO: REMOVE IN 2.5.0////////////////////////////
while (true) {
WiFiClient _client = _server.available();
WiFiClient _client = _server.accept();

if (!_client)
break;
Expand Down
2 changes: 1 addition & 1 deletion libraries/ESP8266WiFiMesh/src/TcpIpMeshBackend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ void TcpIpMeshBackend::acceptRequests()
}

while (true) {
WiFiClient _client = _server.available();
WiFiClient _client = _server.accept();

if (!_client)
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ void loop(void) {
MDNS.update();

// Check if a client has connected
WiFiClient client = server.available();
WiFiClient client = server.accept();
if (!client) {
return;
}
Expand Down
2 changes: 1 addition & 1 deletion libraries/Netdump/src/Netdump.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ void Netdump::tcpDumpLoop(WiFiServer &tcpDumpServer, const Filter nf)
{
if (tcpDumpServer.hasClient())
{
tcpDumpClient = tcpDumpServer.available();
tcpDumpClient = tcpDumpServer.accept();
tcpDumpClient.setNoDelay(true);

bufferIndex = 0;
Expand Down

0 comments on commit a96309c

Please sign in to comment.