             else { throw POSIXError(.ECONNRESET) }
         
         await target.receive(data)
-        Task.detached(priority: .high) { [weak self] in
-            await self?.event(.write(data.count))
-        }
+        eventContinuation.yield(.write(data.count))
     }
     
     /// Reads from the socket.

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

        
        let data = self.receivedData.removeFirst()
        cache.append(data)
        eventContinuation.yield(.read(data.count))
        return data
    }
    
    fileprivate func receive(_ data: Data) {
        receivedData.append(data)
        print("L2CAP Socket: \(name) recieved \([UInt8](data))")
        eventContinuation.yield(.pendingRead)
    }
    
    fileprivate func connect(to socket: TestL2CAPSocket) {
