aboutsummaryrefslogtreecommitdiffstats
path: root/camel/camel-tcp-stream-raw.c
diff options
context:
space:
mode:
authorJeffrey Stedfast <fejj@ximian.com>2001-01-16 07:31:40 +0800
committerJeffrey Stedfast <fejj@src.gnome.org>2001-01-16 07:31:40 +0800
commitffe3a796eda21cb75c6e0c6678b5bb20fb49c79f (patch)
tree8a709193f9d99faf0ce6e1c30825c43dc98fd8dd /camel/camel-tcp-stream-raw.c
parentfeccdbccfbf9fa1c4d2f8b4d50da3a764d475089 (diff)
downloadgsoc2013-evolution-ffe3a796eda21cb75c6e0c6678b5bb20fb49c79f.tar.gz
gsoc2013-evolution-ffe3a796eda21cb75c6e0c6678b5bb20fb49c79f.tar.zst
gsoc2013-evolution-ffe3a796eda21cb75c6e0c6678b5bb20fb49c79f.zip
Updated to be able to get the CAMEL_SOCKOPT_NONBLOCKING socket opt.
2001-01-15 Jeffrey Stedfast <fejj@ximian.com> * camel-tcp-stream-raw.c (stream_getsockopt): Updated to be able to get the CAMEL_SOCKOPT_NONBLOCKING socket opt. (stream_setsockopt): Updated to be able to set the CAMEL_SOCKOPT_NONBLOCKING socket opt. svn path=/trunk/; revision=7519
Diffstat (limited to 'camel/camel-tcp-stream-raw.c')
-rw-r--r--camel/camel-tcp-stream-raw.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/camel/camel-tcp-stream-raw.c b/camel/camel-tcp-stream-raw.c
index 5c884fd136..53722034de 100644
--- a/camel/camel-tcp-stream-raw.c
+++ b/camel/camel-tcp-stream-raw.c
@@ -247,6 +247,17 @@ stream_getsockopt (CamelTcpStream *stream, CamelSockOptData *data)
if ((optname = get_sockopt_optname (data)) == -1)
return -1;
+ if (data->option == CAMEL_SOCKOPT_NONBLOCKING) {
+ long flags;
+
+ if (fcntl (((CamelTcpStreamRaw *)stream)->sockfd, F_GETFL, &flags) == -1)
+ return -1;
+
+ data->value.non_blocking = flags & O_NONBLOCK;
+
+ return 0;
+ }
+
return getsockopt (((CamelTcpStreamRaw *)stream)->sockfd,
get_sockopt_level (data),
optname,
@@ -262,6 +273,21 @@ stream_setsockopt (CamelTcpStream *stream, const CamelSockOptData *data)
if ((optname = get_sockopt_optname (data)) == -1)
return -1;
+ if (data->option == CAMEL_SOCKOPT_NONBLOCKING) {
+ guint32 flags, set;
+
+ if (fcntl (((CamelTcpStreamRaw *)stream)->sockfd, F_GETFL, &flags) == -1)
+ return -1;
+
+ set = data->value.non_blocking ? 1 : 0;
+ flags = (flags & ~O_NONBLOCK) | (set & O_NONBLOCK);
+
+ if (fcntl (((CamelTcpStreamRaw *)stream)->sockfd, F_SETFL, flags) == -1)
+ return -1;
+
+ return 0;
+ }
+
return setsockopt (((CamelTcpStreamRaw *)stream)->sockfd,
get_sockopt_level (data),
optname,