         if dispatchSource != nil {
             throw punosError(0, "Already running")
         }
+        sourceGroup = dispatch_group_create()
         dispatchSource = createDispatchSource(try Socket.tcpSocketForListen(listenPort))
         guard let source = dispatchSource else {
             throw punosError(0, "Could not create dispatch source")

            } else {
                self.log("Closed listening socket \(listeningSocketFD)")
            }
            dispatch_group_leave(self.sourceGroup)
        }
        
        dispatch_source_set_event_handler(source) { _ in

    }
    
    func stop() {
        guard let source = dispatchSource, group = sourceGroup else {
            return
        }
        
        self.dispatchSource = nil
        self.sourceGroup = nil
        
        dispatch_source_cancel(source)
        
        // Wait until the cancellation handler has been called, which
        // guarantees that the listening socket is closed.
        //
        dispatch_group_wait(group, DISPATCH_TIME_FOREVER)
    }
    
    var responder: ((HttpRequest, (HttpResponse) -> Void) -> Void)?
