//服务器端
public class Client {
public static void main(String[] args) throws UnknownHostException, IOException {
// TODO Auto-generated method stub
Scanner input = new Scanner(System.in);
try {
while(true){
//步骤1:创建Socket对象
Socket s = new Socket("127.0.0.1",10086);
System.out.println("客户端启动。。。");
//步骤2:获取输入输出流
OutputStream out = s.getOutputStream();
InputStream in = s.getInputStream();
//步骤3:处理数据
System.out.print("客户端请输入消息:");
String str = input.nextLine();
out.write(str.getBytes());
byte[] buf = new byte[1024];
int len = in.read(buf);
//String str = new String(buf);
String str2 = new String(buf,0,len);
System.out.println("客户端接收到信息:"+str2)