Skip to content

Commit

Permalink
Merge pull request #4148 from Neradoc/fix-recv_into
Browse files Browse the repository at this point in the history
Fix socket.recv_into receiving one less byte than expected
  • Loading branch information
hierophect authored Feb 8, 2021
2 parents a10ce39 + 6be2466 commit 1043d61
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions ports/esp32s2/common-hal/socketpool/Socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ bool common_hal_socketpool_socket_connect(socketpool_socket_obj_t* self,
opts = opts | O_NONBLOCK;
lwip_fcntl(self->num, F_SETFL, opts);

if (result) {
if (result >= 0) {
self->connected = true;
return true;
} else {
Expand Down Expand Up @@ -256,7 +256,7 @@ mp_uint_t common_hal_socketpool_socket_recv_into(socketpool_socket_obj_t* self,
timed_out = supervisor_ticks_ms64() - start_ticks >= self->timeout_ms;
}
RUN_BACKGROUND_TASKS;
received = lwip_recv(self->num, (void*) buf, len - 1, 0);
received = lwip_recv(self->num, (void*) buf, len, 0);

// In non-blocking mode, fail instead of looping
if (received == -1 && self->timeout_ms == 0) {
Expand Down

0 comments on commit 1043d61

Please sign in to comment.