如果app主动发起外联,是client。
连接时,可以指定本机ip。
下文的方法3。
Initiate Connection to a Server:
To make a connection to a server, create a new Socket object using one of the following constructors:
- Socket(InetAddress address, int port)
- Socket(String host, int port)
- Socket(InetAddress address, int port, InetAddress localAddr, int localPort)
You see, it requires the IP address/hostname of the server and the port number.
With the first two constructors, the system automatically assigns a free port number and a local address for the client computer. With the third constructor, you can explicitly specify the address and port number of the client if needed. The first constructor is often used because of its simplicity.
【 在 wisedd 的大作中提到: 】
: 比如我有
: eth0 10.0.0.0
: eth1 10.0.1.0
: ...................
--来自微水木3.5.11
--
修改:zhangkung FROM 114.242.250.*
FROM 114.242.250.*