Show More
@@ -113,9 +113,13 b' else:' | |||||
113 | wifexited = getattr(os, "WIFEXITED", lambda x: False) |
|
113 | wifexited = getattr(os, "WIFEXITED", lambda x: False) | |
114 |
|
114 | |||
115 | # Whether to use IPv6 |
|
115 | # Whether to use IPv6 | |
116 |
def check |
|
116 | def checksocketfamily(name, port=20058): | |
117 |
"""return true if we can listen on localhost |
|
117 | """return true if we can listen on localhost using family=name | |
118 | family = getattr(socket, 'AF_INET6', None) |
|
118 | ||
|
119 | name should be either 'AF_INET', or 'AF_INET6'. | |||
|
120 | port being used is okay - EADDRINUSE is considered as successful. | |||
|
121 | """ | |||
|
122 | family = getattr(socket, name, None) | |||
119 | if family is None: |
|
123 | if family is None: | |
120 | return False |
|
124 | return False | |
121 | try: |
|
125 | try: | |
@@ -133,7 +137,8 b' def checkipv6available(port=20058):' | |||||
133 | else: |
|
137 | else: | |
134 | return False |
|
138 | return False | |
135 |
|
139 | |||
136 | useipv6 = checkipv6available() |
|
140 | # IPv6 is used if IPv4 is not available and IPv6 is available. | |
|
141 | useipv6 = (not checksocketfamily('AF_INET')) and checksocketfamily('AF_INET6') | |||
137 |
|
142 | |||
138 | def checkportisavailable(port): |
|
143 | def checkportisavailable(port): | |
139 | """return true if a port seems free to bind on localhost""" |
|
144 | """return true if a port seems free to bind on localhost""" |
General Comments 0
You need to be logged in to leave comments.
Login now