-
Notifications
You must be signed in to change notification settings - Fork 187
Hello World
小马哥 edited this page Nov 30, 2016
·
3 revisions
首先让我们从 Hello World 开始。
package hprose.tcphelloexam;
import hprose.server.HproseTcpServer;
public class TCPHelloServer {
public static String hello(String name) {
return "Hello " + name + "!";
}
public static void main(String[] args) throws Exception {
HproseTcpServer server = new HproseTcpServer("tcp://localhost:4321");
server.add("hello", TCPHelloServer.class);
server.start();
System.out.println("START");
System.in.read();
server.stop();
System.out.println("STOP");
}
}
package hprose.tcphelloexam;
import hprose.client.HproseTcpClient;
interface IHello {
String hello(String name);
}
public class TCPHelloClient {
public static void main(String[] args) throws Throwable {
System.out.println("START");
HproseTcpClient client = new HproseTcpClient("tcp://localhost:4321");
IHello helloClient = client.useService(IHello.class);
System.out.println(helloClient.hello("World"));
System.out.println("END");
}
}
Hprose for Java 用户手册