📄 simpleclient.java
字号:
package remotecall;
import java.io.*;
import java.net.*;
import java.util.*;
public class SimpleClient {
public void invoke()throws Exception{
Socket socket = new Socket("localhost",8000);
OutputStream out=socket.getOutputStream();
ObjectOutputStream oos=new ObjectOutputStream(out);
InputStream in=socket.getInputStream();
ObjectInputStream ois=new ObjectInputStream(in);
//Call call=new Call("remotecall.HelloService","getTime",new Class[]{},new Object[]{});
Call call=new Call("remotecall.HelloService","echo",new Class[]{String.class},new Object[]{"Hello"});
oos.writeObject(call);
call=(Call)ois.readObject();
System.out.println(call.getResult());
ois.close();
oos.close();
socket.close();
}
public static void main(String args[])throws Exception {
new SimpleClient().invoke();
}
}
/****************************************************
* 作者:孙卫琴 *
* 来源:<<Java网络编程精解>> *
* 技术支持网址:www.javathinker.org *
***************************************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -