         
         fd = sfd
         acceptClients()
-        print("[BRHTTPServer] Serving on \(port)")
-    }
-    
-    func stop() {
+        print("[BRHTTPServer] listening on \(port)")
+    }
+    
+    func shutdownServer() {
         Darwin.shutdown(fd, SHUT_RDWR)
         close(fd)
         fd = -1

                    }
                }
            }
            self.stop()
        }
    }
    

            Darwin.shutdown(cli_fd, SHUT_RDWR)
        }
        self.clients.removeAll(keepCapacity: true)
        print("[BRHTTPServer] no longer listening")
    }
    
    func stop() {
        shutdownServer()
        // background
        NSNotificationCenter.defaultCenter().removeObserver(
            self, name: UIApplicationDidEnterBackgroundNotification, object: nil)
        NSNotificationCenter.defaultCenter().removeObserver(
            self, name: UIApplicationWillResignActiveNotification, object: nil)
        // foreground
        NSNotificationCenter.defaultCenter().removeObserver(
            self, name: UIApplicationWillEnterForegroundNotification, object: nil)
        NSNotificationCenter.defaultCenter().removeObserver(
            self, name: UIApplicationDidBecomeActiveNotification, object: nil)
    }
    
    func suspend(_: NSNotification) {
        if isStarted {
            shutdownServer()
            print("[BRHTTPServer] suspended")
        } else {
            print("[BRHTTPServer] already suspended")
        }
    }
    
    func resume(_: NSNotification) {
        if !isStarted {
            do {
                try listenServer(port)
                print("[BRHTTPServer] resumed")
            } catch let e {
                print("[BRHTTPServer] unable to start \(e)")
            }
        } else {
            print("[BRHTTPServer] already resumed")
        }
    }
    
    func addClient(cli_fd: Int32) {
