Reputation: 2002
My server is creating a IPV6 socket.
On client I am creating a IPV4 socket. Now, In the connect API on client side I am passing the socket descriptor of IPV4 and IPV6 address structure.
INET_connect( sock,(SocketAddress *)in6_addr,(int)sizeof( sockaddr_in6 ) ) == 0 )
where
struct sockaddr_in6 in6_addr;
I am getting error in connection. Is it due to this or some other reason ? Please note that my server is IPV6(having an IPV6 address)
Upvotes: 0
Views: 833
Reputation: 4356
On client I am creating a IPV4 socket
Why? Don't do that. If your client program creates an AF_INET socket (or is running on ip4-only OS) then there is nothing you can do on the client side to make such connection happen.
If you just have to do so - then it is the server that should be adapted to handle IPv4 clients.
Server might be able to accept a connection request from ip4 client - but it can only happen if server side disables IPV6_V6ONLY socket option and, obviously, if server's OS allows that. In this case ip6 server will see the ip4 client via ipv4-mapped ipv6 address.
Upvotes: 3
Reputation: 70909
You must use an IPV6 socket to connect to an IPV6 address, or use a tunneling service which will translate traffic from IPV4 addresses to and from IPV6 addresses.
Upvotes: 4