错误 - 使用本地IP的Java套接字(不是localhost ip)

时间:2015-11-26 11:14:54

标签: java sockets udp

当我尝试使用我的本地IP(而不是localhost)创建套接字时,我收到此错误:

Failed to bind UDP channel to endpoint [/172.25.1.20:11111]
java.net.BindException: Cannot assign requested address: bind

以下是代码:

DatagramSocket dsocket = new DatagramSocket(null);
dsocket.bind(new InetSocketAddress("172.25.1.20", port));

我正在使用Windows 8,我的防火墙已关闭。

任何想法?

0 个答案:

没有答案
相关问题