Why does my service always bind to ipv6 localhost instead of ipv4?

后端 未结 1 1073
孤街浪徒
孤街浪徒 2021-02-20 02:45

I have a service that creates a ServerSocket and binds to localhost:7060. When I did \"netstat -an\" on my android device, I see it is using ipV6 localhost instead

1条回答
  •  隐瞒了意图╮
    2021-02-20 03:44

    In theory a IPv6 server listens to IPv4 as well, since IPv4 address space is a subset of IPv6, is this causing real problems to you?

    A trick that might work is to use "127.0.0.1" instead of "localhost", which has IPv4 and IPv6 addresses associated.

    0 讨论(0)
提交回复
热议问题