aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlanfer <lanfer@9697cf00-7f2a-4e1b-af3c-314b8e4b499e>2000-06-15 12:29:49 +0000
committerlanfer <lanfer@9697cf00-7f2a-4e1b-af3c-314b8e4b499e>2000-06-15 12:29:49 +0000
commit3303c6bc1618b45467005a31a46f0cbd67b772e4 (patch)
tree33a97b5c4d80d7de13011fd7e003db22bfdc088c
parent739e22c8482adcf9421dd01217e865caed4c5be9 (diff)
adding routine to set socket connection to non-blocking
git-svn-id: http://svn.cactuscode.org/arrangements/CactusConnect/Socket/trunk@6 9697cf00-7f2a-4e1b-af3c-314b8e4b499e
-rw-r--r--src/SocketUtils.h5
-rw-r--r--src/Utils.c15
2 files changed, 20 insertions, 0 deletions
diff --git a/src/SocketUtils.h b/src/SocketUtils.h
index 61ba6a0..37931c0 100644
--- a/src/SocketUtils.h
+++ b/src/SocketUtils.h
@@ -88,11 +88,16 @@ int Socket_TCPBlockingWrite(int fd, char *buffer, int buflen);
** to stderr, define PERRORS.
**=================================================================*/
int Socket_TCPBlockingRead(int fd,char *buffer,int buflen);
+
+
+int Socket_SetNonBlocking(int sock);
+
#else
int Socket_TCPOpenClientSock();
int Socket_TCPOpenServerSock();
int Socket_TCPBlockingWrite();
int Socket_TCPBlockingRead();
+int Socket_SetNonBlocking();
#endif
#define PERRORS
diff --git a/src/Utils.c b/src/Utils.c
index 62e95c7..4aee4c0 100644
--- a/src/Utils.c
+++ b/src/Utils.c
@@ -23,6 +23,8 @@
#include <netdb.h>
#include <sys/errno.h>
#include <arpa/inet.h>
+#include <fcntl.h>
+#include <unistd.h>
#include "SocketUtils.h"
@@ -409,3 +411,16 @@ int Socket_TCPBlockingRead(int fd,char *buffer, int buflen)
return accum;
}
}
+
+int Socket_SetNonBlocking(int sock)
+{
+ int retval,ierr;
+ ierr = fcntl (sock, F_SETFL, O_NONBLOCK);
+
+ if (ierr<0)
+ retval = -1;
+ else
+ retval = 0;
+
+ return(retval);
+}