public class MyServer {
//tcp
public static void main(String[] args) {
try {
ServerSocket server = new ServerSocket(8866);
while(true){
//拿到客户端的socket
Socket socket = server.accept();
BufferedReader br = new BufferedReader(new InputStreamReader(socket.getInputStream()));
PrintStream ps = new PrintStream(socket.getOutputStream());
//读的客户端发过来的内容 abc
String readLine = br.readLine();
String result = new StringBuffer(readLine).reverse().toString();
ps.println(result);
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
服务端
最新推荐文章于 2023-09-13 00:43:26 发布