I do more trace this issue.
When server.socket_host is "::" on Win 8.1, my server listen from IPv4, IPv6
My server can be connected from IPv4, IPv6.
Protocol Local Address Remote Address State
TCP 0.0.0.0:7070 0.0.0.0:0 LISTENING
TCPV6 [0:0:0:0:0:0:0:0]:7070 [0:0:0:0:0:0:0:0]:0 LISTENING
When server.socket_host is "0:0:0:0:0:0:0:0" on Win 8.1, my server listen from IPv6
But, IOError occurred after about 50 seconds.
My server can be connected from IPv6 only in about 50 seconds.
Protocol Local Address Remote Address State
TCPV6 [0:0:0:0:0:0:0:0]:7070 [0:0:0:0:0:0:0:0]:0 LISTENING
When server.socket_host is "::" on CentOS 7, my server listen from IPv6 only.
However my server can be connected from IPv4, IPv6.
[root@localhost cqprefserver]# netstat -apn | grep 7070
tcp6 0 0 :::7070 :::* LISTEN 5695/python
When server.socket_host is "0:0:0:0:0:0:0:0" on CentOS 7, my server listen from IPv6 only.
However my server can be connected from IPv4, IPv6 and IOError don't occurred.
[root@localhost cqprefserver]# netstat -apn | grep 7070
tcp6 0 0 :::7070 :::* LISTEN 29574/python
To works well, check_port() in wait_for_occupied_port() must raise IOError.
To check, I write the small test script refer to check_port() function in \Lib\site-packages\cherrypy\process\servers.py
import socket
#host = "::"
host = "0:0:0:0:0:0:0:0"
#host = "0.0.0.0"
port = 7070
timeout = 1.0
info = socket.getaddrinfo(host, port, socket.AF_UNSPEC,
socket.SOCK_STREAM)
print info
af, socktype, proto, canonname, sa = info[0]
s = socket.socket(af, socktype, proto)
s.settimeout(timeout)
s.connect((host, port))
s.close()
Above script works well on CentOS 7, python 2.7.5.
But error occurred on Win 8.1, python 2.7.11.
D:\test>testport.py
[(23, 1, 0, '', ('::', 7070, 0, 0))]
File "D:\test\testport.py", line 18, in <module>
s.connect((host, port))
File "C:\devtool\py27x86\lib\socket.py", line 228, in meth
return getattr(self._sock,name)(*args)
socket.error: [Errno 10049]
IOError occurred by this error on Win 8.1
I modify the client_host() function in \Lib\site-packages\cherrypy\process\servers.py
def client_host(server_host):
"""Return the host on which a client can connect to the given listener."""
if server_host == '0.0.0.0':
# 0.0.0.0 is INADDR_ANY, which should answer on localhost.
return '127.0.0.1'
if server_host in ('::', '::0', '::0.0.0.0', '0:0:0:0:0:0:0:0'): # add '0:0:0:0:0:0:0:0'
# :: is IN6ADDR_ANY, which should answer on localhost.
# ::0 and ::0.0.0.0 are non-canonical but common
# ways to write IN6ADDR_ANY.
return '::1'
return server_host
My server works well on Win 8.1
[29/Mar/2016:15:11:03] ENGINE Bus STARTING
[29/Mar/2016:15:11:03] ENGINE Started monitor thread '_TimeoutMonitor'.
[29/Mar/2016:15:11:03] ENGINE Started monitor thread 'Autoreloader'.
[29/Mar/2016:15:11:03] ENGINE Serving on http://0:0:0:0:0:0:0:0:7070
[29/Mar/2016:15:11:03] ENGINE Bus STARTED
However, it seemed impossible to listen from IPv6 only on CentOS 7.
2016년 3월 23일 수요일 오후 5시 28분 27초 UTC+9, young-kyun Kim 님의 말: