diff --git a/src/dap_events.c b/src/dap_events.c
index 495b556115ba8ca837a0b07cf7065ad4de88b2e0..cb33a50014f64c2e92090145818b07e1597dbb11 100755
--- a/src/dap_events.c
+++ b/src/dap_events.c
@@ -332,6 +332,14 @@ static void *thread_worker_function( void *arg )
         continue;
       }
 
+      //connection already closed (EPOLLHUP - shutdown has been made in both directions)
+      if(events[n].events & EPOLLHUP && events[n].events & EPOLLERR) {
+          log_it( L_DEBUG,"Socket error (EPOLLHUP): 0x%x",events[n].events );
+          if(!(events[n].events & EPOLLIN))
+              cur->no_close = false;
+          cur->flags |= DAP_SOCK_SIGNAL_CLOSE;
+      }
+
       if ( events[n].events & EPOLLERR ) {
         log_it( L_ERROR,"Socket error: %s",strerror(errno) );
         cur->flags |= DAP_SOCK_SIGNAL_CLOSE;