[zeromq-dev] IPv6 support?

dhruva dhruva at ymail.com
Tue Jul 28 13:34:15 CEST 2009

 I wrote the following script (regexp) to match standard compliant IP addresses (IPv4/IPv6). Might come handy. We had a requirement to get parse the URI and hence the following examples. I am following up with my employer so that I can start getting involved more actively.

#!/usr/bin/env perl
# Some valid address formats
my @addrs = ();
push (@addrs,'http://some.thing.host.com:80/some/path?q=hello');
push (@addrs,'http://3m.some.thing.host.com:80/some/path?q=hello');
push (@addrs,'');
push (@addrs,'http://[22:11:11:23:80/some/path/how?q=hello');
push (@addrs,'http://[22:11:11:23]:80/some/path/are?q=hello');
push (@addrs,'http://[22::11:11:23]/some/path?q=hello?tag=how');

for $a (@addrs) {
  if ($a =~ m/([a-zA-Z]+)(\:\/\/)(((\[)([a-zA-Z0-9\-\:]+)(\]))|(([a-zA-Z0-9\-\.]+)))(\:[0-9]+)?(\/)?(([a-zA-Z0-9%]+\/?)+)?(.+)/) {
    print "Matching: $a\n";
    print "\ttransport: $1\n";
    print "\taddress: $3\n";
    if ($10) {
      print "\tport: $10\n";
    if ($12) {
      print "\tpath: $12\n";
    if ($14) {
      print "\tquery: $14\n";
  } else {
    print "Could not match: $a\n";


----- Original Message ----
> From: Martin Sustrik <sustrik at fastmq.com>
> To: dhruva <dhruva at ymail.com>
> Cc: ZeroMQ <zeromq-dev at lists.zeromq.org>
> Sent: Tuesday, 28 July, 2009 4:23:30 PM
> Subject: Re: [zeromq-dev] IPv6 support?
> Hi Dhruva,
> >  Does 0MQ support IPv6? If not, could someone let me know areas that need IPv6 
> support. As part of my
> > day job I have worked on successfully converting a large code base to support 
> IPv6, I can help.
> I would say you should give it a try. That way we'll find out what the actual 
> problems are and gradually move to solve them.
> Parsing IPv6 network addresses would be a good point to start IMO (see ip.cpp). 
> The problem is that colons in IPv6 address would collide with colon used as a 
> port separator.
> Here's what wikipedia says about the topic:
> Since an IPv6 address contains colon (":") characters, network administrators 
> must take care to avoid conflicts with other syntactic meanings of the colon in 
> network resource labels. In IPv4 the colon is used to separate an IP address 
> from a transport protocol port number. This usage has been extended to IPv6, 
> however, when a port is specified in an address string, the proper IPv6 address 
> must be enclosed in square brackets ("[", "]"). This convention is used in other 
> more complex identifiers.
> Example: In a URL the IPv6 address is enclosed in brackets, e.g., 
> http://[2001:0db8:85a3:08d3:1319:8a2e:0370:7348]/.
> If the URL also contains a port number the notation is:
> https://[2001:0db8:85a3:08d3:1319:8a2e:0370:7344]:443/
> This is not only useful but mandated when using the short form:
> https://[2001:db8::1428:57ab]:443/
> Additional information can be found in "RFC 2732 - Format for Literal IPv6 
> Addresses in URL's" and "RFC 3986 - Uniform Resource Identifier (URI): Generic 
> Syntax."
> Thoughts?
> Martin

      Looking for local information? Find it on Yahoo! Local http://in.local.yahoo.com/

More information about the zeromq-dev mailing list