     public init(_ socket: CFSocketNativeHandle) {
         sock = socket
         super.init(data: Data())
+    }
+
+    deinit {
+        sock.closeAll()
     }
 
     public override func read(_ buffer: UnsafeMutablePointer<UInt8>, maxLength len: Int) -> Int {


    public override var streamStatus: Status {
        return status
    }
}


        var fd = pollfd(fd: Int32(self), events: events, revents: 0)
        return poll(&fd, 1, 0) > 0
    }

    func closeAll() {
        close(Int32(self))
    }
}

public class DNSSDNetServiceInputStream: InputStream {
    var sock: CFSocketNativeHandle
    var cffd: CFFileDescriptor?
    var status = Status.open

    /// Initialise from a `CFSocketNativeHandle`
