import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.net.ServerSocket; import java.net.Socket; public class TransServer { public static void main(String[] args) throws IOException{ @SuppressWarnings("resource") ServerSocket ss=new ServerSocket(10004); Socket s=ss.accept(); String ip =s.getInetAddress().getHostAddress(); System.out.println("ip......"+ip); BufferedReader bufin=new BufferedReader(new InputStreamReader(s.getInputStream())); PrintWriter out=new PrintWriter(s.getOutputStream(),true); String line = null; while((line=bufin.readLine())!=null) { System.out.print(line); out.println(line.toUpperCase()); } s.close(); ss.close(); } } |