diff --git a/mongoose.c b/mongoose.c
index fadf708089e34625795772e9c34550f5d255d53f..97535a107e5d0288eb92329624895b6d970221a3 100644
--- a/mongoose.c
+++ b/mongoose.c
@@ -769,7 +769,7 @@ int ns_server_poll(struct ns_server *server, int milli) {
   time_t current_time = time(NULL);
 
   if (server->listening_sock == INVALID_SOCKET &&
-      server->active_connections == NULL) return 0;
+      server->active_connections == NULL) return -1;
 
   FD_ZERO(&read_set);
   FD_ZERO(&write_set);