Skip to content

Commit

Permalink
examples/multi_webcamera: Fix stuck the app
Browse files Browse the repository at this point in the history
Re-create server socket when accept() returned error.

When the error occurred, the application appeared to be stuck.
This situation could occur sometime. (e.g. when WiFi connection was
disassociated).
  • Loading branch information
SPRESENSE committed Jul 26, 2022
1 parent 06eb413 commit 347789d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 6 additions & 0 deletions examples/multi_webcamera/multiwebcam_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,12 @@ int main(int argc, FAR char *argv[])
printf("Finish Jpeg thread.\n");
wsock = 0;
}
else
{
printf("Accept is failed. Re-create server socket\n");
rsock = multiwebcam_initserver(MULTIWEBCAM_PORT_NO);
}

sleep(1);
}

Expand Down
8 changes: 1 addition & 7 deletions examples/multi_webcamera/multiwebcam_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,7 @@ static int send_binary(int s, const char *data, int len)

if (ret == 0)
{
/* It may fail to write when the host browser is stopped due to
* network error. In this case, it returns an error to terminate
* this thread and waits for new socket reconnection.
*/

printf("Error. Cannot send socket.\n");
return -1;
printf("Send 0 byte. Maybe poor reception..\n");
}

if (ret < 0)
Expand Down

0 comments on commit 347789d

Please sign in to comment.