libssh2 lib with ipv6 not working

352 views Asked by At

In my iOS application I am using libssh2 library. I am trying to ssh with ipv6 address, But socket is not creating and getting nil socket. It's working fine with ipv4 address.

static CFSocketRef _CreateSocketConnectedToHost(NSString* name, UInt16 port, CFOptionFlags callBackTypes, CFSocketCallBack callback, const CFSocketContext* context, CFTimeInterval timeOut)

I have search for this but not finding any result for ipv6 support with libssh2.

Please help me, Is libssh2 not supporting for ipv6? Can we make it working using libssh2?

1

There are 1 answers

0
Niks On BEST ANSWER

just need to use ipv6 property in socket instead of ipv4 and you able to create socket with ipv6 address.

struct sockaddr_in6 ipAddress6;
CFSocketSignature           signature;

ipAddress6.sin6_port = htons(port);
signature.protocolFamily = AF_INET6;
signature.protocol = IPPROTO_IP;//IPPROTO_IPV6;
signature.address = (CFDataRef)[NSData dataWithBytes:&ipAddress6 length:ipAddress6.sin6_len];