src/windows/native/sun/nio/ch/WindowsAsynchronousSocketChannelImpl.c

Print this page

        

@@ -155,18 +155,17 @@
 {
     SOCKET s = (SOCKET) jlong_to_ptr(socket);
     WSABUF* lpWsaBuf = (WSABUF*) jlong_to_ptr(address);
     OVERLAPPED* lpOverlapped = (OVERLAPPED*) jlong_to_ptr(ov);
     BOOL res;
-    DWORD nread = 0;
     DWORD flags = 0;
 
     ZeroMemory((PVOID)lpOverlapped, sizeof(OVERLAPPED));
     res = WSARecv(s,
                   lpWsaBuf,
                   (DWORD)count,
-                  &nread,
+                  NULL,
                   &flags,
                   lpOverlapped,
                   NULL);
 
     if (res == SOCKET_ERROR) {

@@ -173,21 +172,16 @@
         int error = WSAGetLastError();
         if (error == WSA_IO_PENDING) {
             return IOS_UNAVAILABLE;
         }
         if (error == WSAESHUTDOWN) {
-            return 0;       // input shutdown
+            return IOS_EOF;       // input shutdown
         }
         JNU_ThrowIOExceptionWithLastError(env, "WSARecv failed");
         return IOS_THROWN;
     }
-    if (nread == 0) {
-        // Handle graceful close or bytes not yet available cases
-        // via completion port notification.
         return IOS_UNAVAILABLE;
-    }
-    return (jint)nread;
 }
 
 JNIEXPORT jint JNICALL
 Java_sun_nio_ch_WindowsAsynchronousSocketChannelImpl_write0(JNIEnv* env, jclass this,
     jlong socket, jint count, jlong address, jlong ov)

@@ -194,17 +188,16 @@
 {
     SOCKET s = (SOCKET) jlong_to_ptr(socket);
     WSABUF* lpWsaBuf = (WSABUF*) jlong_to_ptr(address);
     OVERLAPPED* lpOverlapped = (OVERLAPPED*) jlong_to_ptr(ov);
     BOOL res;
-    DWORD nwritten;
 
     ZeroMemory((PVOID)lpOverlapped, sizeof(OVERLAPPED));
     res = WSASend(s,
                   lpWsaBuf,
                   (DWORD)count,
-                  &nwritten,
+                  NULL,
                   0,
                   lpOverlapped,
                   NULL);
 
     if (res == SOCKET_ERROR) {

@@ -216,7 +209,7 @@
             return IOS_EOF;     // output shutdown
         }
         JNU_ThrowIOExceptionWithLastError(env, "WSASend failed");
         return IOS_THROWN;
     }
-    return (jint)nwritten;
+    return IOS_UNAVAILABLE;
 }