         
         dispatch_source_set_event_handler(source) { _ in
             autoreleasepool {
-                var remoteSockAddr = sockaddr()
-                var remoteSockAddrLen: socklen_t = 0
-                let clientSocket = accept(listeningSocketFD, &remoteSockAddr, &remoteSockAddrLen)
-                guard 0 < clientSocket else {
-                    self.log("Failed to accept socket: \(String(strerror(errno)))")
-                    return
-                }
-                
-                Socket.setNoSigPipe(clientSocket)
-                
-                dispatch_async(self.queue) {
-                    self.handleConnection(Socket(socketFileDescriptor: clientSocket))
-                    Socket.release(clientSocket)
+                do {
+                    let clientSocket = try listeningSocket.acceptClientSocket()
+                    Socket.setNoSigPipe(clientSocket.socketFileDescriptor)
+                    self.handleConnection(clientSocket)
+                    Socket.release(clientSocket.socketFileDescriptor)
+                } catch let error {
+                    self.log("Failed to accept socket. Error: \(error)")
                 }
             }
         }

    private let sourceGroup = dispatch_group_create()
    private var dispatchSource: dispatch_source_t?
    
    private func createDispatchSource(listeningSocketFD: Int32) -> dispatch_source_t {
        dispatch_group_enter(sourceGroup)
        let source = dispatch_source_create(DISPATCH_SOURCE_TYPE_READ, UInt(listeningSocketFD), 0, queue)
        

    }
    
    override func start(listenPort: in_port_t) throws {
        dispatchSource = createDispatchSource(try Socket.tcpSocketForListen(listenPort))
        guard let source = dispatchSource else {
            throw punosError(0, "Could not create dispatch source")
        }
