 import SystemPackage
 
 /// L2CAP Bluetooth socket
-public final class L2CAPSocket {
+public final class L2CAPSocket: L2CAPSocketProtocol {
     
     // MARK: - Properties
     
     /// Internal socket file descriptor
+    @usableFromInline
     internal let fileDescriptor: FileDescriptor
     
     /// L2CAP Socket address

    /// Attempt to accept an incomping connection.
    public func accept() throws -> L2CAPSocket {
        let (clientFileDescriptor, clientAddress) = try fileDescriptor.accept(L2CAPSocketAddress.self)
        let newSocket = L2CAPSocket(
            fileDescriptor: clientFileDescriptor,
            address: clientAddress
        )
        return newSocket
    }
    
    /// Reads from the socket.
    public func recieve(_ bufferSize: Int = 1024) throws -> Data {
        
        var buffer = Data(repeating: 0, count: bufferSize)
        let recievedByteCount = try buffer.withUnsafeMutableBytes {

    /// Attempt to get L2CAP socket options.
    public func getSocketOptions() throws -> L2CAPSocketOption.Options {
        return try fileDescriptor.getSocketOption(L2CAPSocketOption.Options.self)
    }
}

public extension L2CAPSocket {
    
    /// The socket's security level.
    @available(*, deprecated, message: "Use throwing 'securityLevel()'")
    var securityLevel: SecurityLevel {
        return (try? _securityLevel()) ?? .sdp
    }
}

