Login
User Name:

Password:



Register
Forgot your password?
Vote for Us!
Couple bugs
Dec 12, 2017, 5:42 pm
By Remcon
Bug in disarm( )
Nov 12, 2017, 6:54 pm
By GatewaySysop
Bug in will_fall( )
Oct 23, 2017, 1:35 am
By GatewaySysop
Bug in do_zap( ), do_brandish( )
Oct 18, 2017, 1:52 pm
By GatewaySysop
Bug in get_exp_worth( )
Oct 10, 2017, 1:26 am
By GatewaySysop
LOP 1.45
Author: Remcon
Submitted by: Remcon
LOP Heroes Edition
Author: Vladaar
Submitted by: Vladaar
Heroes sound extras
Author: Vladaar
Submitted by: Vladaar
6Dragons 4.3
Author: Vladaar
Submitted by: Vladaar
Memwatch
Author: Johan Lindh
Submitted by: Vladaar
Users Online
CommonCrawl, Google, DotBot, Bing

Members: 0
Guests: 12
Stats
Files
Topics
Posts
Members
Newest Member
477
3,705
19,232
608
LAntorcha
Today's Birthdays
There are no member birthdays today.
Related Links
» SmaugMuds.org » 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, 4:28 pm
Go to the top of the page
Go to the bottom of the page

Samson
Black Hand
GroupAdministrators
Posts3,639
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, 7:32 pm
Go to the top of the page
Go to the bottom of the page

Kayle
Off the Edge of the Map
GroupAdministrators
Posts1,195
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, 8:15 pm
Go to the top of the page
Go to the bottom of the page

Samson
Black Hand
GroupAdministrators
Posts3,639
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, 12:47 am   Last edited Dec 29, 2011, 12:48 am by Samson
Go to the top of the page
Go to the bottom of the page

Samson
Black Hand
GroupAdministrators
Posts3,639
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, 9:54 am
Go to the top of the page
Go to the bottom of the page

GatewaySysop
Conjurer
GroupMembers
Posts367
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, 11:42 am
Go to the top of the page
Go to the bottom of the page

Samson
Black Hand
GroupAdministrators
Posts3,639
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 May 31, 2012, 10:48 pm
Go to the top of the page
Go to the bottom of the page

GatewaySysop
Conjurer
GroupMembers
Posts367
JoinedMar 7, 2005

Checking in to see if anything new has developed on this front? Anyone? :thinking:
       
Post is unread #28 Jun 6, 2012, 10:02 pm
Go to the top of the page
Go to the bottom of the page

Samson
Black Hand
GroupAdministrators
Posts3,639
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, 12:31 pm   Last edited Jun 13, 2012, 12: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 13, 2012, 11:39 pm
Go to the top of the page
Go to the bottom of the page

GatewaySysop
Conjurer
GroupMembers
Posts367
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, 11:41 am
Go to the top of the page
Go to the bottom of the page

GatewaySysop
Conjurer
GroupMembers
Posts367
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, 7:17 pm
Go to the top of the page
Go to the bottom of the page

Samson
Black Hand
GroupAdministrators
Posts3,639
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, 4:40 pm
Go to the top of the page
Go to the bottom of the page

GatewaySysop
Conjurer
GroupMembers
Posts367
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 >>