Code example for Socket

Methods: getInputStreamgetOutputStream

0
      // Wait (blocking) for an incoming connection 
      socket = serverSocket.accept();
      System.out.println("Client connected");
 
      // Setup the streams 
      out = new PrintStream(socket.getOutputStream(), true);
      in =
          new BufferedReader(new InputStreamReader(socket.getInputStream(),
              "UTF8")); 
    } catch (IOException e) {
      // Something went wrong and we were unable to set up a connection. This is 
      // pretty 
      // much a fatal error. 
      // Note: The server does not get restarted automatically if this happens. 
      e.printStackTrace();
      System.exit(1);
    } 
 
    // Enter the main program loop. 
    IOLoop(); 
  }