Visit Jeremy's Blog.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 07-01-2005, 07:21 AM   #1
LQ Newbie
Registered: Jul 2005
Posts: 5

Rep: Reputation: 0
Thumbs down 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.

Old 07-03-2005, 03:25 PM   #2
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,545

Rep: Reputation: 160Reputation: 160
Please show fragments of your code, especially all socket-related functions.
Old 07-04-2005, 04:23 AM   #3
LQ Newbie
Registered: Jul 2005
Posts: 5

Original Poster
Rep: Reputation: 0
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..
Old 07-05-2005, 05:21 PM   #4
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,545

Rep: Reputation: 160Reputation: 160
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.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
(98)Address already in use: make_sock: could not bind to address bruvajon Linux - Software 34 11-30-2011 03:08 PM
IPV6 BIND 9.2 PTR Record toraghun Linux - Networking 3 08-18-2005 03:42 AM
getting IPv6 address lacitpo Linux - Networking 1 03-18-2005 11:09 AM
DNS IPv6 Queries Fail kawauso-kun Debian 1 01-15-2005 05:31 PM
error binding address/port blackzone Linux - Networking 1 09-03-2004 02:23 AM

All times are GMT -5. The time now is 05:52 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration