client socket

Socket socket = new Socket("211.238.142.106", 10000); System.out.println("connected to" + socket.getRemoteSocketAddress()); OutputStream nos = socket.getOutputStream(); InputStream nis = socket.getInputStream(); PrintStream nout = new PrintStream(nos, true); Scanner nscan = new Scanner(nis); Scanner scan = new Scanner(System.in); String msg; do { msg = scan.nextLine(); nout.println(msg); String echo = nscan.nextLine(); System.out.println(echo); } while (!msg.equals("bye")); nout.close(); nscan.close(); nis.close(); nos.close(); socket.close();

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.