我有一个非常奇怪的问题。当我打开端口49262
final static int TRANSFER_PORT = 49262;
ServerSocket data = new ServerSocket(TRANSFER_PORT);
并尝试连接到它
Socket serverData = new Socket(serverCommand.getRemoteSocketAddress().toString(), TRANSFER_PORT);
我有这个例外:
java.net.UnknownHostException: /127.0.0.1:49890
at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.<init>(Unknown Source)
at java.net.Socket.<init>(Unknown Source)
at org.poseydonco.hivescontrol.FileTransfer.receiveFile(FileTransfer.java:67)
at org.poseydonco.hivescontrol.server.ClientConnection.run(ClientConnection.java:49)
但是为什么socket尝试连接到端口49890.在构造函数中我使用了端口49262.也许,我是因为我尝试创建第二个ServerSocket对象。但我必须做什么?