Skip to content

Commit 1b171bb

Browse files
committed
mock new WiFiServer methods defined in esp8266#8216
1 parent ac4af38 commit 1b171bb

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

tests/host/common/MockWiFiServerSocket.cpp

+21-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ void WiFiServer::begin ()
9999
exit(EXIT_FAILURE);
100100
}
101101

102-
server.sin_family = AF_INET;
102+
server.sin_family = AF_INET;
103103
server.sin_port = htons(mockport);
104104
server.sin_addr.s_addr = htonl(global_source_address);
105105
if (bind(sock, (struct sockaddr*)&server, sizeof(server)) == -1)
@@ -150,3 +150,23 @@ void WiFiServer::stop ()
150150
{
151151
close();
152152
}
153+
154+
size_t WiFiServer::hasClientData ()
155+
{
156+
// Trivial Mocking:
157+
// There is no waiting list of clients in this trivial mocking code,
158+
// so the code has to act as if the tcp backlog list is full,
159+
// and nothing is known about potential further clients.
160+
// It could be implemented by accepting new clients and store their data until the current one is closed.
161+
return 0;
162+
}
163+
164+
bool WiFiServer::hasMaxPendingClients ()
165+
{
166+
// Mocking code does not consider the waiting client list,
167+
// so it will return ::hasClient() here meaning:
168+
// - our waiting client list does not exist
169+
// - we consider pending number is max if a new client is waiting
170+
// or not max if there's no new client.
171+
return hasClient();
172+
}

0 commit comments

Comments
 (0)