             Darwin.shutdown(cli_fd, SHUT_RDWR)
         }
         self.clients.removeAll(keepCapacity: true)
-        print("[BRHTTPServer] no longer serving")
+        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) {

        throw BRHTTPServerError.SocketBindFailed
    }
    
    func start(port: in_port_t, maxPendingConnections: Int32 = SOMAXCONN) throws {
        stop()
        
        let sfd = socket(AF_INET, SOCK_STREAM, 0)
        if sfd == -1 {

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