LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices


Reply
  Search this Thread
Old 07-01-2005, 07:21 AM   #1
ydb82
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.

Thanks
yash
 
Old 07-03-2005, 03:25 PM   #2
Mara
Moderator
 
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,696

Rep: Reputation: 232Reputation: 232Reputation: 232
Please show fragments of your code, especially all socket-related functions.
 
Old 07-04-2005, 04:23 AM   #3
ydb82
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..
thnks
yash
 
Old 07-05-2005, 05:21 PM   #4
Mara
Moderator
 
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,696

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


Reply



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 0.0.0.0:443 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

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

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

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