ipv6 program doubt
For the server side , i did something like
int s = -1;
struct addrinfo hints={0}, *result, *ptr;
hints.ai_family = AF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
hints.ai_protocol = IPPROTO_TCP;
hints.ai_flags = AI_PASSIVE;
rc = getaddrinfo( NULL, ”5001”, &hints, &result );
If ( 0 != rc ) {
// error
}
for(ptr=result; ptr != NULL ;ptr=ptr->ai_next)
{
s = socket( ptr->ai_family, ptr->ai_socktype,
ptr->ai_protocol );
bind( s, ptr->ai_addr, ptr->ai_addrlen );
listen( s, SOMAXCONN );
// Add ‘s’ to a list
}
The first bind succeeds , but the second fails with "Address already in use" ..
I even used setsockopt SO_REUSEADDR ..
I still get the error ..
This is on red hat 9 ..
anyone knows how i can go abot this ..
Basically i need one ipv4 and ipv6 socket for a particular port number ..
Thanks
|