Skip to content

Commit

Permalink
Added Socket.setOption()
Browse files Browse the repository at this point in the history
  • Loading branch information
colemancda committed May 5, 2022
1 parent 724d275 commit b9d880f
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions Sources/Socket/Socket.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 <T: SocketOption> (_ option: T.Type) -> T {
get throws {
return try fileDescriptor.getSocketOption(option)
}
}

/// Set socket option.
public func setOption <T: SocketOption> (_ option: T) throws {
try fileDescriptor.setSocketOption(option)
}
}

// MARK: - Supporting Types
Expand Down

0 comments on commit b9d880f

Please sign in to comment.