Skip to content

Commit d601bc8

Browse files
jrowbergsandeepmistry
authored andcommitted
Fix endPacket() return value if socket is unbound
The endPacket() method returns 0 (failure) only in the case where WiFiSocket.sendto() returns < 0. However, the sendto() method returns exactly 0 in the case where the socket is not in a BOUND state. This allows endPacket() to indicate success after sendto() indicates failure. The simple fix is to change the condition to be <= 0 instead of < 0.
1 parent c2830f8 commit d601bc8

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/WiFiUdp.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ int WiFiUDP::endPacket()
137137

138138
int result = WiFiSocket.sendto(_socket, (void *)_sndBuffer, _sndSize, 0, (struct sockaddr *)&addr, sizeof(addr));
139139

140-
return (result < 0) ? 0 : 1;
140+
return (result <= 0) ? 0 : 1;
141141
}
142142

143143
size_t WiFiUDP::write(uint8_t byte)

0 commit comments

Comments
 (0)