Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void runServer() {
- int port = 3000;
- try {
- ServerSocket ss = new ServerSocket(port);
- System.out.println("Waiting for a client...");
- Socket socket = ss.accept();
- System.out.println("Got a client! " + socket.getInetAddress().getHostAddress());
- DataInputStream in = new DataInputStream(socket.getInputStream());
- DataOutputStream out = new DataOutputStream(socket.getOutputStream());
- String line = null;
- while(true) {
- line = in.readUTF();
- System.out.println("Input line : " + line);
- System.out.print("Sending back... ");
- out.writeUTF(line);
- out.flush();
- System.out.println("Done!");
- }
- } catch(Exception x) {
- System.out.print("Lost Connected");
- }
- }
Add Comment
Please, Sign In to add comment