Would it be possible to run Flask to listen in both IPv4 and IPv6 (i.e. dual IP stack)? As far as I checked it is possible to run either in IPv4 using:
app.run(host='0.0.0.0', port=port, debug=True)
or IPv6 using
app.run(host='::', port=port, debug=True)
but I haven't find a way of running in both at the same time (it is possible to have an instance of my Flask application listening to IPv4 and another instance listening to IPv6, but both cannot listen to the same port).
Thanks!
Update (additional info):
Followingt Sander Steffann comments (thanks!), I have started my app listening in IPv6:
* Running on http://[::]:1028/
* Restarting with reloader
Then test with IPv6 and IPv4 curls:
curl -g [::1]:1028/notify
curl 127.0.0.1:1028/notify
getting respectively:
::1 - - [10/Feb/2014 12:04:51] "GET /notify HTTP/1.1" 200 -
::ffff:127.0.0.1 - - [10/Feb/2014 12:05:03] "GET /notify HTTP/1.1" 200 -
My interpretation of the second line is that "somebody" (the OS? the underlying networking libraries in which Flask relies upon?) is converting the IPv4 request to IPv6 request. However, I understand that is not the same that supporting IPv4 "natively" in a classical dual stack setup, i.e. I would have expected something linke this (that is what I get when I run my application (Running on http://0.0.0.0:1028/
)
127.0.0.1 - - [10/Feb/2014 12:05:03] "GET /notify HTTP/1.1" 200 -