1
0
mirror of https://github.com/moparisthebest/curl synced 2024-12-21 23:58:49 -05:00

Change for systems with >1 ways of setting (non-)blocking

mode. (djgpp/Watt-32 has 3 ways). Should rewrite this using
"#elif ..", but maybe there is still broken cpp around?
This commit is contained in:
Gisle Vanem 2005-05-14 05:58:52 +00:00
parent f518a5e231
commit 0c96056a94

View File

@ -133,6 +133,7 @@ int Curl_nonblock(curl_socket_t sockfd, /* operate on this */
int nonblock /* TRUE or FALSE */) int nonblock /* TRUE or FALSE */)
{ {
#undef SETBLOCK #undef SETBLOCK
#define SETBLOCK 0
#ifdef HAVE_O_NONBLOCK #ifdef HAVE_O_NONBLOCK
/* most recent unix versions */ /* most recent unix versions */
int flags; int flags;
@ -145,43 +146,48 @@ int Curl_nonblock(curl_socket_t sockfd, /* operate on this */
#define SETBLOCK 1 #define SETBLOCK 1
#endif #endif
#ifdef HAVE_FIONBIO #if defined(HAVE_FIONBIO) && (SETBLOCK == 0)
/* older unix versions */ /* older unix versions */
int flags; int flags;
flags = nonblock; flags = nonblock;
return ioctl(sockfd, FIONBIO, &flags); return ioctl(sockfd, FIONBIO, &flags);
#undef SETBLOCK
#define SETBLOCK 2 #define SETBLOCK 2
#endif #endif
#ifdef HAVE_IOCTLSOCKET #if defined(HAVE_IOCTLSOCKET) && (SETBLOCK == 0)
/* Windows? */ /* Windows? */
unsigned long flags; unsigned long flags;
flags = nonblock; flags = nonblock;
return ioctlsocket(sockfd, FIONBIO, &flags); return ioctlsocket(sockfd, FIONBIO, &flags);
#undef SETBLOCK
#define SETBLOCK 3 #define SETBLOCK 3
#endif #endif
#ifdef HAVE_IOCTLSOCKET_CASE #if defined(HAVE_IOCTLSOCKET_CASE) && (SETBLOCK == 0)
/* presumably for Amiga */ /* presumably for Amiga */
return IoctlSocket(sockfd, FIONBIO, (long)nonblock); return IoctlSocket(sockfd, FIONBIO, (long)nonblock);
#undef SETBLOCK
#define SETBLOCK 4 #define SETBLOCK 4
#endif #endif
#ifdef HAVE_SO_NONBLOCK #if defined(HAVE_SO_NONBLOCK) && (SETBLOCK == 0)
/* BeOS */ /* BeOS */
long b = nonblock ? 1 : 0; long b = nonblock ? 1 : 0;
return setsockopt(sockfd, SOL_SOCKET, SO_NONBLOCK, &b, sizeof(b)); return setsockopt(sockfd, SOL_SOCKET, SO_NONBLOCK, &b, sizeof(b));
#undef SETBLOCK
#define SETBLOCK 5 #define SETBLOCK 5
#endif #endif
#ifdef HAVE_DISABLED_NONBLOCKING #ifdef HAVE_DISABLED_NONBLOCKING
return 0; /* returns success */ return 0; /* returns success */
#undef SETBLOCK
#define SETBLOCK 6 #define SETBLOCK 6
#endif #endif
#ifndef SETBLOCK #if (SETBLOCK == 0)
#error "no non-blocking method was found/used/set" #error "no non-blocking method was found/used/set"
#endif #endif
} }