Skip to content

Commit fc2f843

Browse files
committed
add support for musl platform
1 parent c308210 commit fc2f843

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

Sources/WebSocketKit/WebSocket+SocketOptions.swift

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,25 @@
11
import Foundation
22
import NIOCore
33

4+
#if canImport(Darwin)
5+
import Darwin
6+
#elseif canImport(Glibc)
7+
import Glibc
8+
#elseif canImport(Musl)
9+
import Musl
10+
#endif
11+
412
extension NIOBSDSocket.Option {
513
#if canImport(Darwin)
614
public static let ip_bound_if: NIOBSDSocket.Option = Self(rawValue: IP_BOUND_IF)
715
public static let ipv6_bound_if: NIOBSDSocket.Option = Self(rawValue: IPV6_BOUND_IF)
8-
#elseif canImport(Glibc)
16+
#elseif canImport(Glibc) || canImport(Musl)
917
public static let so_bindtodevice = Self(rawValue: SO_BINDTODEVICE)
1018
#endif
1119
}
1220

1321
extension SocketOptionProvider {
14-
#if canImport(Glibc)
22+
#if canImport(Glibc) || canImport(Musl)
1523
/// Sets the socket option SO_BINDTODEVICE to `value`.
1624
///
1725
/// - parameters:

Sources/WebSocketKit/WebSocketClient.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ public final class WebSocketClient: Sendable {
181181
default:
182182
return channel.eventLoop.makeFailedFuture(WebSocketClient.Error.invalidAddress)
183183
}
184-
#elseif canImport(Glibc)
184+
#elseif canImport(Glibc) || canImport(Musl)
185185
return (channel as! SocketOptionProvider).setBindToDevice(device.name)
186186
#endif
187187
} else {

0 commit comments

Comments
 (0)