/*
* 创建一个多线程服务端
*
* 接收客户端发送过来的字符串
*
* 打印客户端的地址, 端口号, 发送过来的字符串
*
* 把字符串反转, 再发回去
*/
@SuppressWarnings("resource")
public class Server {
public static void main(String[] args) throws Exception {
ServerSocket serverSocket = new ServerSocket(12345);
while (true) {
final Socket socket = serverSocket.accept();
new Thread(){
public void run() {
try {
String ip = socket.getInetAddress().getHostAddress();
int port = socket.getPort();
BufferedReader br = new BufferedReader(new InputStreamReader(socket.getInputStream()));
PrintStream ps = new PrintStream(socket.getOutputStream());