Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

examples/websocket.c: check for CURLE_AGAIN on recv_pong() #12980

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Theldus
Copy link

@Theldus Theldus commented Feb 24, 2024

Description

The example file docs/examples/websocket.c does not work out of the box, because the recv_pong() function does not consider that the curl_ws_recv() function might return CURLE_AGAIN if there is no data to read, causing the program to terminate prematurely.

This commit addresses this by using select(2) to make receiving pong blocking, and thus being able to continue with the main loop.

This also occurs in the example file sendrecv.c, which also makes use of select(2) for sending and receiving data, which I based on for this commit.

The example file docs/examples/websocket.c does not work out of the
box, because the recv_pong() function does not consider that the
curl_ws_recv() function might return CURLE_AGAIN if there is no data
to read, causing the program to terminate prematurely.

This commit addresses this by using select(2) to make receiving pong
blocking, and thus being able to continue with the main loop.

This also occurs in the example file sendrecv.c, which also makes use
of select(2) for sending and receiving data, which I based on for
this commit.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

None yet

1 participant