apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From traw...@apache.org
Subject svn commit: r1088103 - /apr/apr/trunk/network_io/win32/sendrecv.c
Date Sat, 02 Apr 2011 20:11:54 GMT
Author: trawick
Date: Sat Apr  2 20:11:54 2011
New Revision: 1088103

URL: http://svn.apache.org/viewvc?rev=1088103&view=rev
Log:
apr_socket_wait() for Windows

Modified:
    apr/apr/trunk/network_io/win32/sendrecv.c

Modified: apr/apr/trunk/network_io/win32/sendrecv.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/network_io/win32/sendrecv.c?rev=1088103&r1=1088102&r2=1088103&view=diff
==============================================================================
--- apr/apr/trunk/network_io/win32/sendrecv.c (original)
+++ apr/apr/trunk/network_io/win32/sendrecv.c Sat Apr  2 20:11:54 2011
@@ -457,6 +457,39 @@ APR_DECLARE(apr_status_t) apr_socket_sen
 
 APR_DECLARE(apr_status_t) apr_socket_wait(apr_socket_t *sock, apr_wait_type_t direction)
 {
-    return APR_ENOTIMPL;
+    fd_set fdset, *rptr, *wptr;
+    int rc;
+    struct timeval tv, *tvptr;
+
+    FD_ZERO(&fdset);
+    FD_SET(sock->socketdes, &fdset);
+
+    if (direction == APR_WAIT_READ) {
+        rptr = &fdset;
+        wptr = NULL;
+    }
+    else { /* APR_WAIT_WRITE */
+        rptr = NULL;
+        wptr = &fdset;
+    }
+
+    if (sock->timeout < 0) {
+        tvptr = NULL;
+    }
+    else {
+        /* casts for winsock/timeval definition */
+        tv.tv_sec =  (long)apr_time_sec(sock->timeout);
+        tv.tv_usec = (int)apr_time_usec(sock->timeout);
+        tvptr = &tv;
+    }
+    rc = select(/* ignored */ FD_SETSIZE+1, rptr, wptr, NULL, tvptr);
+    if (rc == SOCKET_ERROR) {
+        return apr_get_netos_error();
+    }
+    else if (!rc) {
+        return APR_FROM_OS_ERROR(WSAETIMEDOUT);
+    }
+
+    return APR_SUCCESS;
 }
 



Mime
View raw message