From 81cbc4e64ddf60645a8d2b510eae82d5d61a75a0 Mon Sep 17 00:00:00 2001 From: Greg Cotten Date: Mon, 24 Mar 2025 09:20:01 -0700 Subject: [PATCH] expose Socket.unlink(...) helpful for those who need a cross-platform way of unlinking a unix address! --- FlyingSocks/Sources/SocketAddress.swift | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/FlyingSocks/Sources/SocketAddress.swift b/FlyingSocks/Sources/SocketAddress.swift index 91da616e..93df5524 100644 --- a/FlyingSocks/Sources/SocketAddress.swift +++ b/FlyingSocks/Sources/SocketAddress.swift @@ -197,6 +197,13 @@ extension Socket { } } + public static func unlink(_ address: sockaddr_un) throws { + var address = address + guard Socket.unlink(&address.sun_path.0) == 0 else { + throw SocketError.makeFailed("unlink") + } + } + static func makeAddressINET(fromIP4 ip: String, port: UInt16) throws -> sockaddr_in { var address = Socket.makeAddressINET(port: port) address.sin_addr = try Socket.makeInAddr(fromIP4: ip) @@ -218,13 +225,6 @@ extension Socket { } return addr } - - static func unlink(_ address: sockaddr_un) throws { - var address = address - guard Socket.unlink(&address.sun_path.0) == 0 else { - throw SocketError.makeFailed("unlink") - } - } } public struct AnySocketAddress: Sendable, SocketAddress {