Hi ,
We are developing an iOS application for ipad that uses bonjour for conneting
with other devices and couchbaseListener for replications with peer databases.
We have observed that whenever [nsnetservice addresses] returns IPV6 address
,replication is not suuccesful.We have tried encoding IPV6 last two components
sayfe80::68c8:cfff:fef9:3856 as 254.249.56.86 and using the same in the url but
still replications fail.
We get the IPV4 address only when bluetooth is switched on randomly i.e 1 out
of 5 times.In other cases ,Peer-Peer Wifi and Infrastructure Wifi only IPV6
address is returned.
In addition to that, [NSNetService addresses] returns only one address from the
array.
Is it possible in some proper way to convert IPV6 address to IPV4 address and
use the same or else retrieve the IPV4 address?
Please find the code used for converting to Ip address below.
char addressBuffer[INET6_ADDRSTRLEN];
for (NSData *data in self.addresses) {
memset(addressBuffer, 0, INET6_ADDRSTRLEN);
typedef union {
struct sockaddr sa;
struct sockaddr_in ipv4;
struct sockaddr_in6 ipv6;
} ip_socket_address;
ip_socket_address *socketAddress = (ip_socket_address *)[data bytes];
if (socketAddress && (socketAddress->sa.sa_family == AF_INET ||
socketAddress->sa.sa_family == AF_INET6))
{
const char *addressStr = inet_ntop(
socketAddress->sa.sa_family,
(socketAddress->sa.sa_family == AF_INET ? (void
*)&(socketAddress->ipv4.sin_addr) : (void *)&(socketAddress->ipv6.sin6_addr)),
addressBuffer,
sizeof(addressBuffer));
int port = ntohs(socketAddress->sa.sa_family == AF_INET ?
socketAddress->ipv4.sin_port : socketAddress->ipv6.sin6_port);
if (addressStr && port)
{
NSLog(@"Found service at %s:%d", addressStr, port);
}
}
Please help .
Thanks & Regards
Lakshminarayana Achar B R
Tata Consultancy Services
Cell:- 9940021554
Mailto: [email protected]
Website: http://www.tcs.com
____________________________________________
Experience certainty. IT Services
Business Solutions
Consulting
____________________________________________
=====-----=====-----=====
Notice: The information contained in this e-mail
message and/or attachments to it may contain
confidential or privileged information. If you are
not the intended recipient, any dissemination, use,
review, distribution, printing or copying of the
information contained in this e-mail message
and/or attachments to it are strictly prohibited. If
you have received this communication in error,
please notify us by reply e-mail or telephone and
immediately and permanently delete the message
and any attachments. Thank you
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list ([email protected])
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/macnetworkprog/archive%40mail-archive.com
This email sent to [email protected]