diff options
author | Yorhel <git@yorhel.nl> | 2015-07-21 01:00:41 +0200 |
---|---|---|
committer | Yorhel <git@yorhel.nl> | 2015-07-21 01:00:41 +0200 |
commit | 7605b38f304f043b1a0947278eca12daad32a608 (patch) | |
tree | 858b99b0dd90518773ae0ac6bf1eb9615de67e31 /lib/Multi | |
parent | c720511e81fe093175926e9ba06cb857a763b4a3 (diff) |
Multi::API: Support IPv6
This was more trivial than I had expected. I already took ipv6 into
account when rewriting the API for AnyEvent (including the use of
norm_ip()), so that part was fine. The only part I had to fix was the
listening socket, and I had to ensure that the $c->{ip} was correct. The
first was easy, and the latter was properly handled by AnyEvent
automatically. Looks like AnyEvent automatically 'unpacks' IPv4-mapped
IPv6 addresses, so I didn't have to deal with that myself.
Diffstat (limited to 'lib/Multi')
-rw-r--r-- | lib/Multi/API.pm | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/Multi/API.pm b/lib/Multi/API.pm index 2385e11d..cce366d1 100644 --- a/lib/Multi/API.pm +++ b/lib/Multi/API.pm @@ -55,7 +55,11 @@ sub run { shift; %O = (%O, @_); - push_watcher tcp_server undef, $O{port}, \&newconn; + push_watcher tcp_server '::', $O{port}, \&newconn; + # The following tcp_server will fail if the above already bound to IPv4. + eval { + push_watcher tcp_server 0, $O{port}, \&newconn; + }; writelog 'API starting up on port %d', $O{port}; } |