8000 Add error handling to “available” function · arduino/ArduinoCore-mbed@ba13416 · GitHub
[go: up one dir, main page]

Skip to content
Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit ba13416

Browse files
committed
Add error handling to “available” function
1 parent c7a98ca commit ba13416

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

libraries/WiFi/src/WiFiServer.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,12 @@ size_t arduino::WiFiServer::write(const uint8_t *buf, size_t size) {
3333
}
3434

3535
arduino::WiFiClient arduino::WiFiServer::available(uint8_t* status) {
36-
WiFiClient ret;
37-
TCPSocket* client = sock->accept();
38-
ret.setSocket(client);
39-
return ret;
36+
WiFiClient client;
37+
nsapi_error_t error;
38+
TCPSocket* clientSocket = sock->accept(&error);
39+
if(status != nullptr) {
40+
*status = error == NSAPI_ERROR_OK ? 1 : 0;
41+
}
42+
client.setSocket(clientSocket);
43+
return client;
4044
}

0 commit comments

Comments
 (0)
0