[swift-users] Pointer conversions between different sockaddr types

Bouke Haarsma bouke at haarsma.eu
Tue Mar 21 15:57:35 CDT 2017


Hi all (again),

It seems the fix is to (only) replace withUnsafePointer with 
withUnsafeMutablePointer twice. No need to apply the @escaping fixit 
even.

--
Bouke

On 2017-03-21 20:52:36 +0000, Bouke Haarsma via swift-users said:

> Hi Quinn, and others,
> 
> I found that this code is still featured on swift.org 
> (https://swift.org/migration-guide/se-0107-migrate.html), but it 
> doesn't compile anymore. There's a fix-it for adding @escaping, but 
> also compile errors due to invalid casts. Can someone have a look at 
> fixing this code?
> 
> --Bouke
> 
> On 2016-08-22 16:31:58 +0000, Quinn \"The Eskimo!\" via swift-users said:
> 
>> 
>> On 18 Aug 2016, at 08:28, Quinn The Eskimo! via swift-users 
>> <swift-users at swift.org> wrote:
>> 
>>> 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.
>> 
>> I’ve been revisiting this issue recently and decided to tidy up my code 
>> enough to share with others.  It’s pasted in below.  Bon apétit!
>> 
>> Share and Enjoy
> 
> 
> 
> _______________________________________________
> swift-users mailing list
> swift-users at swift.org
> https://lists.swift.org/mailman/listinfo/swift-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20170321/0daf6e8d/attachment.html>


More information about the swift-users mailing list