     
     let address: BluetoothAddress
     
-    private(set) var event: ((L2CAPSocketEvent) async -> ()) = { _ in }
+    public let event: L2CAPSocketEventStream
     
-    func setEvent(_ event: @escaping ((L2CAPSocketEvent) async -> ())) async {
-        self.event = event
-    }
+    private var eventContinuation: L2CAPSocketEventStream.Continuation!
     
     /// The socket's security level.
     private(set) var securityLevel: SecurityLevel = .sdp

        
        let data = self.receivedData.removeFirst()
        cache.append(data)
        Task.detached(priority: .high) { [weak self] in
            await self?.event(.read(data.count))
        }
        return data
    }
    
    fileprivate func receive(_ data: Data) {
        receivedData.append(data)
        print("L2CAP Socket: \(name) recieved \([UInt8](data))")
        Task.detached(priority: .high) { [weak self] in
            await self?.event(.pendingRead)
        }
    }
    
    fileprivate func connect(to socket: TestL2CAPSocket) {

            else { throw POSIXError(.ECONNRESET) }
        
        await target.receive(data)
        eventContinuation.yield(.write(data.count))
    }
    
    /// Reads from the socket.
