-
Notifications
You must be signed in to change notification settings - Fork 53
Open
Description
As I understand it, withSockAddr() unsafely casts an existential to a sockaddr, which does work reliably, possibly for alignment reasons. On my system it fails (returns garbage) with domain sockets. Round-tripping via sockaddr_storage seems to work for me.
In my unrelated SocketAddress package [1], withSockAddr is a requirement of the protocol, so you get a pointer to the non-existential (underlying C type).
public protocol SocketAddress: Sendable {
static var family: sa_family_t { get }
init(family: sa_family_t, presentationAddress: String) throws
func withSockAddr<T>(_ body: (_ sa: UnsafePointer<sockaddr>) throws -> T) rethrows -> T
var presentationAddress: String { get throws }
var presentationAddressNoPort: String { get throws }
var port: UInt16 { get throws }
var size: socklen_t { get }
}Metadata
Metadata
Assignees
Labels
No labels