import java.net.*;
import java.io.*;
class L
{
public static void main(String args[]) throws Exception
{
Socket s=new Socket("192.168.1.101",407);//查
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
BufferedWriter bwOut=new BufferedWriter(new OutputStreamWriter(s.getOutputStream()));
BufferedReader brIn=new BufferedReader(new InputStreamReader(s.getInputStream()));
String line=null;
while((line=br.readLine())!=null)
{
if(line.equals("886"))
break;
bwOut.write(line);
bwOut.newLine();
bwOut.flush();
String line1=brIn.readLine();
System.out.println(line1);
}
br.close();
s.close();
}
}
class L1
{
public static void main(String args[]) throws Exception
{
ServerSocket ss=new ServerSocket(407);
Socket s=ss.accept();
String ip=s.getInetAddress().getHostAddress();
System.out.println(ip+"......connected");
BufferedReader brIn=new BufferedReader(new InputStreamReader(s.getInputStream()));
BufferedWriter bwOut=new BufferedWriter(new OutputStreamWriter(s.getOutputStream()));
String line=null;
while((line=brIn.readLine())!=null)
{
System.out.println(line);
bwOut.write(line.toUpperCase());
bwOut.newLine();
bwOut.flush();
}
ss.close();
s.close();
}
}
Tcp: 从客户端传数据,服务端接收后,转成大写,客户端接收(自编)
最新推荐文章于 2021-09-25 17:55:32 发布