import java.net.*;
import java.io.*;
class khd
{
public static void main(String[] args) throws Exception
{
Socket khd=new Socket("127.0.0.1",4788);
BufferedReader jp=
new BufferedReader(new InputStreamReader(System.in)); //定义键盘录入
BufferedWriter fs=
new BufferedWriter(new OutputStreamWriter(khd.getOutputStream()));
BufferedReader dq=
new BufferedReader(new InputStreamReader(khd.getInputStream()));
String f=null;
while ((f=jp.readLine())!=null)
{
if ("over".equals(f))
break;
fs.write(f);
fs.newLine();
fs.flush();
String str=dq.readLine();
System.out.println("Server:"+str);
}
jp.close();
khd.close();
}
}
class fwd
{
public static void main(String[] args) throws Exception
{
ServerSocket fwq=new ServerSocket(4788);
Socket s=fwq.accept();
//BufferedReader jp=new BufferedReader(new InputStreamReader(System.in));
BufferedWriter fs=
new BufferedWriter(new OutputStreamWriter(s.getOutputStream()));
BufferedReader dq=
new BufferedReader(new InputStreamReader(s.getInputStream()));
String f=null;
while ((f=dq.readLine())!=null)
{
System.out.println(f);
fs.write(f.toUpperCase());
fs.newLine();
fs.flush();
}
s.close();
fwq.close();
}
}
|
|