aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2003-10-05 15:02:58 +0000
committerDaniel Stenberg <daniel@haxx.se>2003-10-05 15:02:58 +0000
commit57b6202eaaee82af17e0a64e643a8dbf7c3d9f9a (patch)
treefebc76c96cdb2528cbcac0ae7c97933dc2c81813
parent0bbe184f1fa5add861f40b7fad022835dd54675e (diff)
New code for BeOS-style non-blocking sockets, provided by Shard and
Jeremy Friesner.
-rw-r--r--lib/connect.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/lib/connect.c b/lib/connect.c
index e19a01b2d..92298d3fe 100644
--- a/lib/connect.c
+++ b/lib/connect.c
@@ -103,6 +103,7 @@ int Curl_nonblock(int socket, /* operate on this */
{
#undef SETBLOCK
#ifdef HAVE_O_NONBLOCK
+ /* most recent unix versions */
int flags;
flags = fcntl(socket, F_GETFL, 0);
@@ -114,6 +115,7 @@ int Curl_nonblock(int socket, /* operate on this */
#endif
#ifdef HAVE_FIONBIO
+ /* older unix versions */
int flags;
flags = nonblock;
@@ -122,6 +124,7 @@ int Curl_nonblock(int socket, /* operate on this */
#endif
#ifdef HAVE_IOCTLSOCKET
+ /* Windows? */
int flags;
flags = nonblock;
return ioctlsocket(socket, FIONBIO, &flags);
@@ -129,13 +132,21 @@ int Curl_nonblock(int socket, /* operate on this */
#endif
#ifdef HAVE_IOCTLSOCKET_CASE
+ /* presumably for Amiga */
return IoctlSocket(socket, FIONBIO, (long)nonblock);
#define SETBLOCK 4
#endif
+#ifdef HAVE_SO_NONBLOCK
+ /* BeOS */
+ long b = nonblock ? 1 : 0;
+ return setsockopt(socket, SOL_SOCKET, SO_NONBLOCK, &b, sizeof(b));
+#define SETBLOCK 5
+#endif
+
#ifdef HAVE_DISABLED_NONBLOCKING
return 0; /* returns success */
-#define SETBLOCK 5
+#define SETBLOCK 6
#endif
#ifndef SETBLOCK
@@ -348,11 +359,11 @@ int socketerror(int sockfd)
{
int err = 0;
socklen_t errSize = sizeof(err);
-
+#ifdef SO_ERROR
if( -1 == getsockopt(sockfd, SOL_SOCKET, SO_ERROR,
(void *)&err, &errSize))
err = Curl_ourerrno();
-
+#endif
return err;
}