bind() fail while binding to an IPv6 Address
I enabled IPv6 on Redhat Linux 7.3 and Redhat AS 3.
I have written a sample Client and Server program using the IPv4/IPv6 compatible socket calls. When i give IPv4 address, the server binds and listens to client connections. But when i give IPv6 Address, bind fails as below bind() failed with error 22: Invalid argument ifconfig -a lists both IPv4 and IPv6 addresses. I am able to ping both the addresses. This same code works fine on Solaris,AIX,Windows,HPUX but on both the Linux distributions its not working. Please help. Thanks yash |
Please show fragments of your code, especially all socket-related functions.
|
Thanks mara for your reply..
here is the code fragment Client Code : RetVal = getaddrinfo("fe80::210:b5ff:fea6:d412", "16000", &Hints, &AI); ConnSocket = socket(AI->ai_family, AI->ai_socktype, AI->ai_protocol); i = connect(ConnSocket, (struct sockaddr *)AI->ai_addr, AI->ai_addrlen); Socket Code : RetVal = getaddrinfo("fe80::210:b5ff:fea6:d412%eth0", "16000", &Hints, &AI); ServSock1 = socket(AI->ai_family, AI->ai_socktype, AI->ai_protocol); i = bind(ServSock1, (struct sockaddr *)AI->ai_addr, AI->ai_addrlen); i = listen(ServSock1, 5); earlier i dint give the "%eth0" along with the address in the server code.. hence the bind was getting failed. After giving tht bind got succeded but now i am havng a problem on the client side. the connect() is getting failed with the following message "Error Connection establishment, error 22: Invalid argument" Please help.. thnks yash |
It's hard to say without seeing all the values you pass, but I'd look into AI->ai_addrlen. Better, print out the values. Maybe the protocl doesn't make sense etc.
|
All times are GMT -5. The time now is 09:50 AM. |