public interface HelloService { String sayHello(String name); } public class HelloServiceImpl implements HelloService { public String sayHello(String name) { return "Hello, " + name + "!"; } } public class ServerMain { public static void main(String[] args) { Server server = new Server(8000); server.registerService(new HelloServiceImpl()); server.start(); } } public class ClientMain { public static void main(String[] args) { Client client = new Client("localhost", 8000); HelloService helloService = client.createProxy(HelloService.class); String result = helloService.sayHello("World"); System.out.println(result); client.stop(); } } <server> <port>8000</port> <maxThreads>100</maxThreads> </server> <client> <serverAddress>localhost:8000</serverAddress> <connectionTimeout>5000</connectionTimeout> <maxRetries>3</maxRetries> </client>


上一篇:
下一篇:
切换中文