diff --git a/Sources/Socket/Socket.swift b/Sources/Socket/Socket.swift index b473dab..913f63c 100644 --- a/Sources/Socket/Socket.swift +++ b/Sources/Socket/Socket.swift @@ -86,9 +86,22 @@ public struct Socket { try await manager.read(length, for: fileDescriptor) } + /// Close socket. public func close() async { await manager.remove(fileDescriptor) } + + /// Get socket option. + public subscript (_ option: T.Type) -> T { + get throws { + return try fileDescriptor.getSocketOption(option) + } + } + + /// Set socket option. + public func setOption (_ option: T) throws { + try fileDescriptor.setSocketOption(option) + } } // MARK: - Supporting Types