//服务器端
public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub//建立socket
ServerSocket ss=new ServerSocket(19000);
//获取客户端的socket
Socket s=ss.accept();
//获取输入流,并装饰
InputStream is=s.getInputStream();
BufferedReader br=new BufferedReader(new InputStreamReader(is));
//获取输出流
OutputStream os=s.getOutputStream();
PrintWriter pw=new PrintWriter(os, true);
String content=null;
while((content=br.readLine())!=null)
{
System.out.println(content);
pw.println(content.toUpperCase());
}
s.close();
ss.close();
}
//客户端
public static void main(String[] args) throws UnknownHostException, IOException {
// TODO Auto-generated method stub
//创建socket
Socket s=new Socket("127.0.0.1", 19000);
//键盘录入流
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
//socket输入流
BufferedReader brin=new BufferedReader(new InputStreamReader(s.getInputStream()));
//socket输出流
PrintWriter pwout=new PrintWriter(s.getOutputStream(), true);
String content=null;
while((content=br.readLine())!=null)
{
if("over".equals(content))
break;
pwout.println(content);
String Upperstr=brin.readLine();
System.out.println(Upperstr);
}
s.close();
br.close();
}