Sockets
int port=2000;
BufferedReader br;
PrintWriter pw;
ServerSocket ss;
Socket sock;
ss = new ServerSocket(port);
sock = ss.accept();
br = new BufferedReader(
new InputStreamReader(
(sock.getInputStream());
pw = new PrintWriter(
sock.getOutputStream());
System.out.println(
br.readLine());
pw.println(“HELLO”);
int port=2000;
String host=“piaget”;
BufferedReader br;
PrintWriter pw;
Socket sock;
sock = new Socket(host,port);
br = new BufferedReader(
new InputStreamReader(
(sock.getInputStream());
pw = new PrintWriter(
sock.getOutputStream());
pw.println(“ciao”);
System.out.println(
br.readLine());
Server
Client
Previous slide
Next slide
Back to first slide
View graphic version