我启动了一个服务器套接字,并希望它监听环回地址(127.0.0.1)。代码如下:......
Inet4Address address = (Inet4Address) Inet4Address.getByName("localhost");
TServerSocket server = new TServerSocket(new InetSocketAddress(address ,1234));
.........
public class TServerSocket{
......
public TServerSocket(InetSocketAddress bindAddr, int clientTimeout) throws TTransportException {
clientTimeout_ = clientTimeout;
try {
serverSocket_ = new ServerSocket();
serverSocket_.setReuseAddress(true);
serverSocket_.bind(bindAddr);
} catch (IOException ioe) {
serverSocket_ = null;
throw new TTransportException("Could not create ServerSocket on address " + bindAddr.toString() + ".");
}
}
......
}
但我发现这个套接字开始使用命令“netstat”监听 IPv6 地址“:ffff:127.0.0.1”,导致在另一个进程中运行的客户端(在 Python 中)无法通过“127.0.0.1”。
为什么android会自动将IPV4地址映射到IPv6地址?