This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author plammens
Recipients asvetlov, plammens, yselivanov
Date 2020-12-31.11:37:16
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1609414637.07.0.323924138606.issue42795@roundup.psfhosted.org>
In-reply-to
Content
When a sequence containing just the empty string (e.g. `['']`) is passed as the `host` parameter of `loop.create_server`, the server seems not to bind to any network interface. Since, per the [documentation](https://docs.python.org/3/library/asyncio-eventloop.html#asyncio.loop.create_server) for `create_server`, the empty string means "bind to all interfaces", 

> If host is an empty string or None all interfaces are assumed and a list of multiple 
> sockets will be returned (most likely one for IPv4 and another one for IPv6).


and also

> The host parameter can also be a sequence (e.g. list) of hosts to bind to.

I would have expected a list containing the empty string to also work as expected, i.e. "binding to all hosts in the sequence", so binding to "" and thus to every interface.

Example:

Server script:

```python
import asyncio


async def server():
    async def connection_callback(reader, writer: asyncio.StreamWriter):
        print(f"got connection from {writer.get_extra_info('peername')}")
        writer.close()
        await writer.wait_closed()

    s = await asyncio.start_server(connection_callback, host=[''], port=4567)
    async with s:
        print("starting server")
        await s.serve_forever()


asyncio.run(server())
```

Client script:

```python
import asyncio


async def client():
    reader, writer = await asyncio.open_connection("127.0.0.1", 4567)
    print(f"connected to {writer.get_extra_info('peername')}")
    writer.close()
    await writer.wait_closed()


asyncio.run(client())
```

Expected:

- Server:
  ```
  starting server
  got connection from ('127.0.0.1', xxxxx)
  ```

- Client:
  ```
  connected to ('127.0.0.1', xxxxx)
  ```

Actual:

- Server:
  ```
  starting server
  ```

- Client: a ConnectionError is raised (the host machine refused the connection)
History
Date User Action Args
2020-12-31 11:37:17plammenssetrecipients: + plammens, asvetlov, yselivanov
2020-12-31 11:37:17plammenssetmessageid: <1609414637.07.0.323924138606.issue42795@roundup.psfhosted.org>
2020-12-31 11:37:17plammenslinkissue42795 messages
2020-12-31 11:37:16plammenscreate