Check the presence of AF_UNIX & IPPROTO_IPV6.

* Proceed with defaults if socket.IPPROTO_IPV6 is not exported

This patch adds a way around: https://bugs.python.org/issue29515

* Add fallback to AF_INET if AF_UNIX is unavailable

xref: https://github.com/google/python_portpicker/issues/4
diff --git a/src/portpicker.py b/src/portpicker.py
index 15b6d59..aee7c39 100644
--- a/src/portpicker.py
+++ b/src/portpicker.py
@@ -224,7 +224,11 @@
 
     try:
         # Create socket.
-        sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
+        if hasattr(socket, 'AF_UNIX'):
+            sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
+        else:
+            # fallback to AF_INET if this is not unix
+            sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
         try:
             # Connect to portserver.
             sock.connect(portserver_address)
diff --git a/src/tests/portpicker_test.py b/src/tests/portpicker_test.py
index b3924cd..e799d01 100644
--- a/src/tests/portpicker_test.py
+++ b/src/tests/portpicker_test.py
@@ -209,6 +209,10 @@
                       file=sys.stderr)
                 # Skip this case, since we cannot occupy a port.
                 continue
+
+            if not hasattr(socket, 'IPPROTO_IPV6'):
+                v6only = None
+
             if v6only is not None:
                 try:
                     sock.setsockopt(socket.IPPROTO_IPV6, socket.IPV6_V6ONLY,