aboutsummaryrefslogtreecommitdiff
path: root/libsylph/socket.c
diff options
context:
space:
mode:
authorhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2006-02-14 08:39:10 +0000
committerhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2006-02-14 08:39:10 +0000
commitd43aa2e692e5689cbd54a4398df51e1f51db3cb9 (patch)
tree69398a9a7e2f60a4e0f3fdbf6f71a494ecf0b5e8 /libsylph/socket.c
parent0162a14d3bf701fea6b0ff4a2b83e94f5d6b29da (diff)
win32: avoid blocking when reading from socket.
git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@1001 ee746299-78ed-0310-b773-934348b2243d
Diffstat (limited to 'libsylph/socket.c')
-rw-r--r--libsylph/socket.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/libsylph/socket.c b/libsylph/socket.c
index 954c33f0..7ddde9e5 100644
--- a/libsylph/socket.c
+++ b/libsylph/socket.c
@@ -398,6 +398,27 @@ gboolean sock_is_nonblocking_mode(SockInfo *sock)
return is_nonblocking_mode(sock->sock);
}
+gboolean sock_has_read_data(SockInfo *sock)
+{
+#ifdef G_OS_WIN32
+ gulong val;
+
+#if USE_SSL
+ if (sock->ssl)
+ return TRUE;
+#endif
+ if (ioctlsocket(sock->sock, FIONREAD, &val) < 0)
+ return TRUE;
+
+ if (val == 0)
+ return FALSE;
+ else
+ return TRUE;
+#else
+ return TRUE;
+#endif
+}
+
static gboolean sock_prepare(GSource *source, gint *timeout)
{