]> git.saurik.com Git - wxWidgets.git/blobdiff - src/unix/gsocket.cpp
Remove const bool
[wxWidgets.git] / src / unix / gsocket.cpp
index eeee3fa8cca875d04ede6be217549614574a471a..e2423cdd2c96d062e9ede15a966d11b604e05016 100644 (file)
@@ -1168,17 +1168,16 @@ int GSocket::Read(char *buffer, int size)
     else
       ret = Recv_Dgram(buffer, size);
 
-    /* If recv returned zero, then the connection is lost, and errno is not set.
+    /* If recv returned zero, then the connection has been gracefully closed.
      * Otherwise, recv has returned an error (-1), in which case we have lost the
      * socket only if errno does _not_ indicate that there may be more data to read.
      */
     if (ret == 0)
     {
-      m_error = GSOCK_IOERR;
+      /* Make sure wxSOCKET_LOST event gets sent and shut down the socket */
       m_detected = GSOCK_LOST_FLAG;
-      Close();
-      // Signal an error for return
-      return -1;
+      Detected_Read();
+      return 0;
     }
     else if (ret == -1)
     {
@@ -1752,6 +1751,12 @@ void GSocket::Detected_Read()
     {
       CALL_CALLBACK(this, GSOCK_CONNECTION);
     }
+    else if (num == 0)
+    {
+      /* graceful shutdown */
+      CALL_CALLBACK(this, GSOCK_LOST);
+      Shutdown();
+    }
     else
     {
       /* Do not throw a lost event in cases where the socket isn't really lost */