Skip to content

Commit 7090f6f

Browse files
authored
Merge pull request #161 from gregcotten/wsa-abstract-sockets-lie
WinSock can't actually support abstract sockets at all...
2 parents 22a3a1e + 7e4d5e2 commit 7090f6f

File tree

3 files changed

+3
-21
lines changed

3 files changed

+3
-21
lines changed

FlyingSocks/Sources/Socket+WinSock2.swift

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -107,24 +107,6 @@ extension Socket {
107107
return addr
108108
}
109109

110-
static func makeAbstractNamespaceUnix(name: String) -> WinSDK.sockaddr_un {
111-
var addr: sockaddr_un = WinSDK.sockaddr_un()
112-
addr.sun_family = ADDRESS_FAMILY(AF_UNIX)
113-
114-
_ = withUnsafeMutableBytes(of: &addr.sun_path) { raw in
115-
raw.initializeMemory(as: CChar.self, repeating: 0)
116-
}
117-
118-
let nameBytes = Array(name.utf8.prefix(107))
119-
nameBytes.withUnsafeBytes { src in
120-
withUnsafeMutableBytes(of: &addr.sun_path) { dst in
121-
dst[1 ..< 1 + src.count].copyBytes(from: src)
122-
}
123-
}
124-
125-
return addr
126-
}
127-
128110
static func fcntl(_ fd: FileDescriptorType, _ cmd: Int32) -> Int32 {
129111
return -1
130112
}

FlyingSocks/Sources/SocketAddress.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public extension SocketAddress where Self == sockaddr_un {
111111
Socket.makeAddressUnix(path: path)
112112
}
113113

114-
#if canImport(Glibc) || canImport(Musl) || canImport(Android) || canImport(WinSDK)
114+
#if canImport(Glibc) || canImport(Musl) || canImport(Android)
115115
static func unix(abstractNamespace: String) -> Self {
116116
Socket.makeAbstractNamespaceUnix(name: abstractNamespace)
117117
}

FlyingSocks/Tests/SocketAddressTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ struct SocketAddressTests {
148148
)
149149
}
150150

151-
#if canImport(Glibc) || canImport(Musl) || canImport(Android) || canImport(WinSDK)
151+
#if canImport(Glibc) || canImport(Musl) || canImport(Android)
152152
@Test
153153
func unixAbstractNamespace_IsCorrectlyDecodedFromStorage() throws {
154154
let storage = sockaddr_un
@@ -200,7 +200,7 @@ struct SocketAddressTests {
200200
)
201201
}
202202

203-
#if canImport(Glibc) || canImport(Musl) || canImport(Android) || canImport(WinSDK)
203+
#if canImport(Glibc) || canImport(Musl) || canImport(Android)
204204
@Test
205205
func unixAbstractNamespace_CheckSize() throws {
206206
let sun = sockaddr_un.unix(abstractNamespace: "some_great_namespace")

0 commit comments

Comments
 (0)