1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-12-04 14:46:47 -05:00

[ win64 ] os dependent socket blocking

This commit is contained in:
Unknown 2022-04-25 08:55:57 +02:00
parent 292f2f9b63
commit eff70d3807
2 changed files with 18 additions and 1 deletions

View File

@ -18,7 +18,7 @@ fix eventual complications.
Let's walkthrough a simple example. In my case the elinks Let's walkthrough a simple example. In my case the elinks
binary compiled in the very minimalistic configuration binary compiled in the very minimalistic configuration
but when I opene http it does throw Socket Exception. but when I opened http it does throw Socket Exception.
First You want to compile the win64 executable using the First You want to compile the win64 executable using the

View File

@ -77,6 +77,13 @@
int int
set_nonblocking_fd(int fd) set_nonblocking_fd(int fd)
{ {
#ifdef WIN32
/* on current mingw (202204)
* this is correct usage of winsock
* when compiling for win32 */
u_long mode = 1; // set non-blocking socket
return ioctlsocket(fd, FIONBIO, &mode);
# else
#if defined(O_NONBLOCK) || defined(O_NDELAY) #if defined(O_NONBLOCK) || defined(O_NDELAY)
int flags = fcntl(fd, F_GETFL, 0); int flags = fcntl(fd, F_GETFL, 0);
@ -94,6 +101,8 @@ set_nonblocking_fd(int fd)
#else #else
return 0; return 0;
#endif #endif
#endif
} }
/* Set a file descriptor to blocking mode. It returns a non-zero value on /* Set a file descriptor to blocking mode. It returns a non-zero value on
@ -101,6 +110,13 @@ set_nonblocking_fd(int fd)
int int
set_blocking_fd(int fd) set_blocking_fd(int fd)
{ {
#ifdef WIN32
/* on current mingw (202204)
* this is correct usage of winsock
* when compiling for win32 */
u_long mode = 0; // set blocking socket
return ioctlsocket(fd, FIONBIO, &mode);
# else
#if defined(O_NONBLOCK) || defined(O_NDELAY) #if defined(O_NONBLOCK) || defined(O_NDELAY)
int flags = fcntl(fd, F_GETFL, 0); int flags = fcntl(fd, F_GETFL, 0);
@ -118,6 +134,7 @@ set_blocking_fd(int fd)
#else #else
return 0; return 0;
#endif #endif
#endif
} }
void void