0

I'm trying to convert this code into Swift, but I don't know how to achieve it:

    struct sockaddr_in6 zeroAddress;
    bzero(&zeroAddress, sizeof(zeroAddress));
    zeroAddress.sin6_len = sizeof(zeroAddress);
    zeroAddress.sin6_family = AF_INET6;
    return [self reachabilityWithAddress: &zeroAddress];

Thank you.

Ahmad F
  • 30,560
  • 17
  • 97
  • 143
Hiren
  • 22
  • 5
  • Compare http://stackoverflow.com/a/25623647/1187415: That uses a `sockaddr_in` (IPv4 socket), but it should be easy to change the code for `sockaddr_in6` (IPv6 socket). – Martin R Oct 19 '16 at 08:01
  • @MartinR i have trying it but how i write this line bzero(&zeroAddress, sizeof(zeroAddress)); in swift – Hiren Oct 19 '16 at 08:16
  • You don't: Just `let zeroAddress = sockaddr_in6()`, that already zero-initializes the struct (as shown and explained in the answer that I linked to). – Martin R Oct 19 '16 at 08:17
  • @MartinR i have convert this code var zeroAddress = sockaddr_in() zeroAddress.sin_len = UInt8(MemoryLayout.size) zeroAddress.sin_family = sa_family_t(AF_INET) to var zeroAddress = sockaddr_in6() zeroAddress.sin6_len = UInt8(MemoryLayout.size) zeroAddress.sin6_family = sa_family_t(AF_INET6) but always get true – Hiren Oct 19 '16 at 08:42
  • It is impossible to read that code in a comment. Please edit your question and include the code that you tried. – Martin R Oct 19 '16 at 08:43
  • Have you tried swiftify. @Hiren – KAR Oct 19 '16 at 09:46
  • yes i have tried but its not work. @KAR – Hiren Oct 19 '16 at 09:53

0 Answers0