"""
if address == "":
address = None
- success = 0
for res in socket.getaddrinfo(address, port, family, socket.SOCK_STREAM,
0, socket.AI_PASSIVE | socket.AI_ADDRCONFIG):
af, socktype, proto, canonname, sockaddr = res
sock.bind(sockaddr)
sock.listen(128)
self._sockets[sock.fileno()] = sock
- success += 1
+ if self._started:
+ self.io_loop.add_handler(sock.fileno(), self._handle_events,
+ ioloop.IOLoop.READ)
def start(self, num_processes=1):
"""Starts this server in the IOLoop.
with closing(socket.socket()) as sock:
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
- sock.bind(('', port))
+ sock.bind(('127.0.0.1', port))
sock.listen(1)
self.http_client.fetch("http://localhost:%d/" % port,
self.stop,
self.assertEqual(response.body, byte_body)
def test_ipv6(self):
+ self.http_server.bind(self.get_http_port(), address='::1')
url = self.get_url("/hello").replace("localhost", "[::1]")
# ipv6 is currently disabled by default and must be explicitly requested
self._app = self.get_app()
self.http_server = HTTPServer(self._app, io_loop=self.io_loop,
**self.get_httpserver_options())
- self.http_server.listen(self.get_http_port())
+ self.http_server.listen(self.get_http_port(), address="127.0.0.1")
def get_app(self):
"""Should be overridden by subclasses to return a