On 17 Aug 2016, at 18:55, Martin R via swift-users <swift-users@swift.org> 
wrote:

> - Are both solutions correct, should one be preferred, or are both wrong?

Your `withMemoryRebound` solution is correct.

> - Can the same be achieved simpler?

Not without introducing a layer of abstraction.

In my case I introduced an abstract `Address` type (basically a wrapper around 
`sockaddr_storage`) and then added a method to that object which calls a 
closure with the right parameters (actually, multiple such methods, depending 
on whether I’m calling something like `connect` which takes an address, or 
`getpeername`, which returns one).  This approach concentrates all the ugly in 
one place, making the rest of my BSD Sockets code much cleaner.

Share and Enjoy
--
Quinn "The Eskimo!"                    <http://www.apple.com/developer/>
Apple Developer Relations, Developer Technical Support, Core OS/Hardware


_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users

Reply via email to