Update docs/examples/websocket.c

Co-authored-by: Viktor Szakats <vszakats@users.noreply.github.com>
This commit is contained in:
Davidson Francis 2025-02-08 16:34:56 -03:00 committed by GitHub
parent e8d0cd0e95
commit a8e2dd54c2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -30,6 +30,14 @@
#include <unistd.h>
#include <curl/curl.h>
/* Avoid warning in FD_SET() with pre-2020 Cygwin/MSYS releases:
* warning: conversion to 'long unsigned int' from 'curl_socket_t' {aka 'int'}
* may change the sign of the result [-Wsign-conversion]
*/
#ifdef __GNUC__
#pragma GCC diagnostic ignored "-Wsign-conversion"
#endif
/* Auxiliary function that waits on the socket. */
static int wait_on_socket(curl_socket_t sockfd, long timeout_ms)
{
@ -44,19 +52,8 @@ static int wait_on_socket(curl_socket_t sockfd, long timeout_ms)
FD_ZERO(&outfd);
FD_ZERO(&errfd);
/* Avoid this warning with pre-2020 Cygwin/MSYS releases:
* warning: conversion to 'long unsigned int' from 'curl_socket_t' {aka 'int'}
* may change the sign of the result [-Wsign-conversion]
*/
#if defined(__GNUC__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wsign-conversion"
#endif
FD_SET(sockfd, &errfd); /* always check for error */
FD_SET(sockfd, &infd);
#if defined(__GNUC__)
#pragma GCC diagnostic pop
#endif
/* select() returns the number of signalled sockets or -1 */
res = select((int)sockfd + 1, &infd, &outfd, &errfd, &tv);