0
我已經創建了節儉服務器和客戶端。然後我開始在我的電腦上使用節儉服務器。我使用我的機器IP地址在LAN中的另一臺計算機上運行客戶端。如何通過節儉客戶端連接到遠程節儉服務器
public class ArithmeticClient {
private void invoke() {
TTransport transport;
try {
transport = new TSocket("192.168.0.232"/*this is my machine,which the sever runs' IP address*/, 7911);
TProtocol protocol = new TBinaryProtocol(transport);
ArithmeticService.Client client = new ArithmeticService.Client(protocol);
transport.open();
long addResult = client.add(100, 200);
System.out.println("Add result: " + addResult);
long multiplyResult = client.multiply(20, 40);
System.out.println("Multiply result: " + multiplyResult);
transport.close();
} catch (TTransportException e) {
e.printStackTrace();
} catch (TException e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
ArithmeticClient c = new ArithmeticClient();
c.invoke();
}
}
而且我得到了一個錯誤
org.apache.thrift.transport.TTransportException: java.net.NoRouteToHostException: No route to host
at org.apache.thrift.transport.TSocket.open(TSocket.java:185)
at ArithmeticClient.invoke(ArithmeticClient.java:18)
at ArithmeticClient.main(ArithmeticClient.java:35)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
Caused by: java.net.NoRouteToHostException: No route to host
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:391)
at java.net.Socket.connect(Socket.java:579)
at org.apache.thrift.transport.TSocket.open(TSocket.java:180)
... 7 more
我該如何解決這件事情。
兩臺電腦都運行Fedora。版本不同(17和19)
防火牆是問題所在。禁用後,我現在可以連接到遠程服務器。 – ddarz4u