Java Socket技术绑定本地接口(ppp0的)(Java Socket Bind Local

2019-10-18 14:19发布

我已经使用ppp0的端点通过这种方式tryied释放一个java socket连接:

Socket socket = new Socket(InetAddress.getByName("200.147.67.142"), 80, InetAddress.getByName("189.116.7.204"), 4447);

其中189.116.7.204是ppp0的界面和200.147.67.142目标IP地址。

问题是:TimeoutException异常

我的网络配置:

ifconfig -a
eth0      Link encap:Ethernet  Endereço de HW b8:27:eb:fb:45:a6
          UP BROADCASTMULTICAST  MTU:1500  Métrica:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          colisões:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

lo        Link encap:Loopback Local
          inet end.: 127.0.0.1  Masc:255.0.0.0
          UP LOOPBACKRUNNING  MTU:16436  Métrica:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          colisões:0 txqueuelen:0
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

ppp0      Link encap:Protocolo Ponto-a-Ponto
          inet end.: 189.116.7.204  P-a-P:10.64.64.64  Masc:255.255.255.255
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1500  Métrica:1
          RX packets:24 errors:0 dropped:0 overruns:0 frame:0
          TX packets:25 errors:0 dropped:0 overruns:0 carrier:0
          colisões:0 txqueuelen:3
          RX bytes:408 (408.0 B)  TX bytes:537 (537.0 B)

wlan0     Link encap:Ethernet  Endereço de HW c8:3a:35:ca:4c:50
          inet end.: 10.0.1.16  Bcast:10.0.1.255  Masc:255.255.255.0
          UP BROADCASTRUNNING MULTICAST  MTU:1500  Métrica:1
          RX packets:35080 errors:0 dropped:1164 overruns:0 frame:0
          TX packets:32267 errors:0 dropped:0 overruns:0 carrier:0
          colisões:0 txqueuelen:1000
          RX bytes:23543046 (22.4 MiB)  TX bytes:11526680 (10.9 MiB)

wwan0     Link encap:Ethernet  Endereço de HW 58:2c:80:13:92:63
          UP BROADCASTRUNNING MULTICAST  MTU:1500  Métrica:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          colisões:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

谢谢你的帮助...

文章来源: Java Socket Bind Local Interface (ppp0)