Login
User Name:

Password:



Register

Forgot your password?
do_owhere recursive
Author: Khonsu
Submitted by: Khonsu
Changes list / Addchange
Author: Khonsu
Submitted by: Khonsu
6Dragons mp3 sound pack
Author: Vladaar
Submitted by: Vladaar
AFKMud 2.2.3
Author: AFKMud Team
Submitted by: Samson
SWFOTEFUSS 1.5
Author: Various
Submitted by: Samson
Users Online
AhrefsBot, Google, Bing

Members: 0
Guests: 32
Stats
Files
Topics
Posts
Members
Newest Member
489
3,791
19,644
596
Elwood

Today's Birthdays
There are no member birthdays today.
» SmaugMuds » General » Coding » IPv6
Forum Rules | Mark all | Recent Posts

IPv6
< Newer Topic :: Older Topic >

Pages:<< prev 1, 2 next >>
Post is unread #21 Dec 26, 2011 6:28 pm   
Go to the top of the page
Go to the bottom of the page

Samson
Black Hand
GroupAdministrators
Posts3,685
JoinedJan 1, 2002

 
Well that's a start I guess. It does look to me like they're only binding one port number, which would be what I was hoping for. I'll see if I can muster some time later to try something on my server and see if it will at least bind. I don't have IPv6 connectivity at home to verify it with though.

Post is unread #22 Dec 28, 2011 9:32 pm   
Go to the top of the page
Go to the bottom of the page

InfiniteAxis
Off the Edge of the Map
GroupAdministrators
Posts1,200
JoinedMar 21, 2006

 
You might try on the VPS. I can't remember if it has IPv6 or not.

Post is unread #23 Dec 28, 2011 10:15 pm   
Go to the top of the page
Go to the bottom of the page

Samson
Black Hand
GroupAdministrators
Posts3,685
JoinedJan 1, 2002

 
Yours doesn't, mine does. I'll take a look at it a bit later.

Post is unread #24 Dec 29, 2011 2:47 am   Last edited Dec 29, 2011 2:48 am by Samson
Go to the top of the page
Go to the bottom of the page

Samson
Black Hand
GroupAdministrators
Posts3,685
JoinedJan 1, 2002

 
Test code for init_socket (ignore the bogus return at the end for now):
int init_socket( int mudport )
{
   struct addrinfo hints, *res, *ptr;
   char mport[MIL];
   int sock[16];
   int rc, count=0;
   int x = 1;

   memset( &hints, 0, sizeof hints );
   hints.ai_family = AF_UNSPEC;
   hints.ai_socktype = SOCK_STREAM;
   hints.ai_protocol = IPPROTO_TCP;
   hints.ai_flags = AI_PASSIVE;

   snprintf( mport, MIL, "%d", mudport );
   if( (rc = getaddrinfo( NULL, mport, &hints, &res )) < 0 )
   {
      perror( "Init_socket: getaddrinfo" );
      exit(1);
   }

   ptr = res;

   while( ptr )
   {
log_printf( "Count: %d", count );
log_printf( "Family: %d, Socktype: %d, Proto: %d", ptr->ai_family, ptr->ai_socktype, ptr->ai_protocol );
      if( (sock[count] = socket( ptr->ai_family, ptr->ai_socktype, ptr->ai_protocol )) < 0 )
      {
         perror( "Init_socket: socket" );
         exit(1);
      }
log_printf( "Sock: %d", sock[count] );
      if( setsockopt( sock[count], SOL_SOCKET, SO_REUSEADDR, ( void * )&x, sizeof( x ) ) < 0 )
      {
         perror( "Init_socket: SO_REUSEADDR" );
         close( sock[count] );
         exit( 1 );
      }

      if( bind( sock[count], ptr->ai_addr, ptr->ai_addrlen ) < 0 )
      {
         perror( "Init_socket: bind" );
         close( sock[count] );
         exit( 1 );
      }

      if( listen( sock[count], 50 ) < 0 )
      {
         perror( "Init_socket: listen" );
         close( sock[count] );
         exit( 1 );
      }
      count++;
      ptr = ptr->ai_next;
   }
   return sock[count];
}


Result:
Thu Dec 29 03:45:58 2011 :: Initializing socket
Thu Dec 29 03:45:58 2011 :: Count: 0
Thu Dec 29 03:45:58 2011 :: Family: 2, Socktype: 1, Proto: 6
Thu Dec 29 03:45:58 2011 :: Sock: 3
Thu Dec 29 03:45:58 2011 :: Count: 1
Thu Dec 29 03:45:58 2011 :: Family: 10, Socktype: 1, Proto: 6
Thu Dec 29 03:45:58 2011 :: Sock: 4
Init_socket: bind: Address already in use


So it's back to the same old crap as before. Not allowing to bind everything to one port, despite the obvious fact that other services on the box are doing so without issue. Something is clearly missing here but I have no idea what.

Post is unread #25 Dec 29, 2011 11:54 am   
Go to the top of the page
Go to the bottom of the page

GatewaySysop
Conjurer
GroupMembers
Posts413
JoinedMar 7, 2005

 
Hmm. I'm curious about this part that I found in one of the later examples at the page I mentioned earlier. Would something like this make a difference?

                        // After the socket descriptor is created, a bind() function gets a
                        // unique name for the socket.  In this example, the user sets the
                        // address to in6addr_any, which (by default) allows connections to
                        // be established from any IPv4 or IPv6 client based on the hostname
                        // that specifies port 7171.
                        // That is, the bind is done to both the IPv4 and IPv6 TCP/IP
                        // stacks. However this sample program only accept the IPv4 hostname, then
                        // the client must prepare to convert the IPv4 address to the hostname
                        // before translating the IP string to network address before making a connection
                        // using various Winsock API such as getaddressinfo() etc.

                        memset(&serveraddr, 0, sizeof(serveraddr));
                        serveraddr.sin6_family = AF_INET6;
                        serveraddr.sin6_port   = htons(SERVER_PORT);

                        // Applications use in6addr_any similarly to the way they use
                        // INADDR_ANY in IPv4.

                        serveraddr.sin6_addr   = in6addr_any;

                        // The remaining fields in the sockaddr_in6 are currently not
                        // supported and should be set to 0 to ensure upward compatibility

                        if (bind(sd, (struct sockaddr *)&serveraddr, sizeof(serveraddr)) == SOCKET_ERROR)


I'm no expert on sockets (maybe someday if I have more time!) but maybe this is helpful. :shrug:

Post is unread #26 Dec 29, 2011 1:42 pm   
Go to the top of the page
Go to the bottom of the page

Samson
Black Hand
GroupAdministrators
Posts3,685
JoinedJan 1, 2002

 
That appears to be wanting to open this as an IPv6 only socket though. Unless there's no other way to do this that's not really what we're after here.

Post is unread #27 Jun 1, 2012 12:48 am   
Go to the top of the page
Go to the bottom of the page

GatewaySysop
Conjurer
GroupMembers
Posts413
JoinedMar 7, 2005

 
Checking in to see if anything new has developed on this front? Anyone? :thinking:

Post is unread #28 Jun 7, 2012 12:02 am   
Go to the top of the page
Go to the bottom of the page

Samson
Black Hand
GroupAdministrators
Posts3,685
JoinedJan 1, 2002

 
Nope. Apparently there's just not enough interest in moving on this. I'd still like to see it get added at some point but only if IPv4 and IPv6 traffic can live on the same port somehow.

I also don't have access to a server with IPv6 capability anymore, nor do I have IPv6 network access at home (yeah, thanks Verizon, for being so backward).

Post is unread #29 Jun 13, 2012 2:31 pm   Last edited Jun 13, 2012 2:38 pm by Kober
Go to the top of the page
Go to the bottom of the page

Kober
Fledgling
GroupMembers
Posts1
JoinedApr 6, 2010

 
Here is my init_socket that seems to work.

int init_socket(int port)
{
  char mport[MIL];
	int sockfd, yes = 1, rv;
	struct addrinfo hints, *servinfo, *p;
	
	memset(&hints, 0, sizeof hints);
	hints.ai_family = AF_UNSPEC;
	/*hints.ai_family = AF_INET;*/
	hints.ai_socktype = SOCK_STREAM;
  hints.ai_protocol = IPPROTO_TCP;
	hints.ai_flags = AI_PASSIVE;
	
  snprintf(mport, MIL, "%d", port);
	if ((rv = getaddrinfo(NULL, mport, &hints, &servinfo)) != 0)
	{
        fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(rv));
        return 1;
    }
	
	for(p = servinfo; p != NULL; p = p->ai_next)
	{
		if((sockfd = socket(p->ai_family, p->ai_socktype, p->ai_protocol)) == -1)
		{
			perror("Init_socket: socket" );
			continue;
		}
		
		if (setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(int)) == -1)
		{
            perror("Init_socket: SO_REUSEADDR" );
			close(sockfd);
            exit(1);
        }
		
#if defined(SO_DONTLINGER) && !defined(SYSV)
		{
			struct linger ld;
			ld.l_onoff=1;
			ld.l_linger=1000;
		
			if(setsockopt(sockfd, SOL_SOCKET, SO_DONTLINGER, (char *)&ld, sizeof(ld))< 0)
			{
				perror( "Init_socket: SO_DONTLINGER" );
				close(sockfd );
				exit( 1 );
			}
		}
#endif

		if (bind(sockfd, p->ai_addr, p->ai_addrlen) == -1)
		{
            perror("Init_socket: bind" );
			close(sockfd);
            continue;
        }
		break;
	}
	
	if (p == NULL)
	{
        fprintf(stderr, "server: failed to bind\n" );
        return 2;
    }
	
	freeaddrinfo(servinfo); // all done with this structure

    if (listen(sockfd, 3) == -1)
	{
        perror("Init_socket: listen" );
		close(sockfd);
        exit(1);
    }
	return sockfd;
}

Post is unread #30 Jun 14, 2012 1:39 am   
Go to the top of the page
Go to the bottom of the page

GatewaySysop
Conjurer
GroupMembers
Posts413
JoinedMar 7, 2005

 
Stumbled on this, thought it might provide some insight on the bind( ) problems. Have not had a chance to play around with it yet.

Binding Sockets to IPv4 and IPv6

Perhaps this is more helpful. :cyclops:

Post is unread #31 Jun 30, 2012 1:41 pm   
Go to the top of the page
Go to the bottom of the page

GatewaySysop
Conjurer
GroupMembers
Posts413
JoinedMar 7, 2005

 
Anyone? :cricket:

I'm going to take a crack at this stuff again as soon as I have time, looks like the link I mentioned might lead to a solution to our problems.

Post is unread #32 Jun 30, 2012 9:17 pm   
Go to the top of the page
Go to the bottom of the page

Samson
Black Hand
GroupAdministrators
Posts3,685
JoinedJan 1, 2002

 
Could be, but I no longer have access to a server with IPv6 capabilities.

Also nice to see the cricket emote get some love :P

Post is unread #33 Oct 27, 2014 6:40 pm   
Go to the top of the page
Go to the bottom of the page

GatewaySysop
Conjurer
GroupMembers
Posts413
JoinedMar 7, 2005

 
Kober said:

Here is my init_socket that seems to work.


Decided to look at this again, along with the link I posted before that talked about IPv4 and IPv6 coexisting. Maybe I'm wrong, but isn't the code from Kober missing only something like this to make it work, at least in theory? :wink:

#ifdef IPV6_V6ONLY
        {
           int v6only = 1;
           if (p->ai_family == AF_INET6 && setsockopt(sockfd, IPPROTO_IPV6, IPV6_V6ONLY, &v6only, sizeof(v6only)) < 0) {
              close(sockfd);
              continue;
           }
        }
#endif


If anyone wants to slap that into Kober's posted code and give it a try, assuming anyone has IPv6 connectivity to make use of, that would be helpful. Would be nice if this was the only missing link. :alien:


Pages:<< prev 1, 2 next >>