Академический Документы
Профессиональный Документы
Культура Документы
Soal3_server
Soal3_client
public class server {
public class soal3_client {
public static void main(String args[]) throws
IOException { public static void main(String args[]) throws
// Register service on port 1254 IOException {
ServerSocket s = new ServerSocket(1254); // Register service on port 1254
Socket s1 = s.accept(); // Wait and accept a Socket s1 = new Socket("192.168.1.15",
connection 1254);
// Get a communication stream associated
with the socket DataInputStream dis = new
DataOutputStream dos = new DataInputStream(s1.getInputStream());
DataOutputStream(s1.getOutputStream()); String st = new String(dis.readUTF());
// Send a string! JOptionPane.showMessageDialog(null, st);
dos.writeUTF("1. Soto \n 2. Bakso \n 3. System.out.println(st);
Sate"); DataOutputStream dos = new
DataOutputStream(s1.getOutputStream());
// Get an input file handle from the socket String a =
and read the input JOptionPane.showInputDialog(null, "Masukkan
DataInputStream dis = new Pilihanmu");
DataInputStream(s1.getInputStream()); dos.writeUTF(a);
String st = new String(dis.readUTF()); DataInputStream dis1 = new
System.out.println(st); DataInputStream(s1.getInputStream());
String st1 = new String(dis1.readUTF());
// Get a communication stream associated JOptionPane.showMessageDialog(null, st1);
with the socket System.out.println(st1);
// When done, just close the connection and DataOutputStream dos = new
exit DataOutputStream(s1.getOutputStream());
dis.close(); String a =
dis1.close(); JOptionPane.showInputDialog(null, "Pesan
mu");
dos.close(); dos.writeUTF(a);
s1.close(); if(konek=false){
} dos.close();
} }
}
Soal4_server
}
public class server { }
}
}
Soal4_client