Esempio n. 1
0
 public void run() // loop utama, utk nerima user input n kirim ke server&client laen
     {
   while (thread != null) {
     try {
       String a = console.readLine();
       String b = cryptor.encrypt(a);
       streamOut.writeUTF(cryptor.encrypt(a));
       streamOut.flush();
     } catch (IOException ioe) {
       System.out.println("Sending error: " + ioe.getMessage());
       stop();
     }
   }
 }
Esempio n. 2
0
  public ChatClient(InetAddress iAddress, int serverPort) {
    System.out.println("Establishing connection. Please wait ...");
    try {
      socket = new Socket(iAddress, serverPort);
      cryptor = new EDCrypt();
      System.out.println("Connected: " + socket);

      start();
    } catch (UnknownHostException uhe) {
      System.out.println("Host unknown: " + uhe.getMessage());
    } catch (IOException ioe) {
      System.out.println("Unexpected exception: " + ioe.getMessage());
    }
  }