-
Notifications
You must be signed in to change notification settings - Fork 0
/
Client4.java
65 lines (57 loc) · 1.91 KB
/
Client4.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
//package Networking4;
/*
* Client4.java
*
* Version:
* $1.1$
*/
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.EOFException;
import java.io.IOException;
import java.io.InputStream;
import java.io.ObjectInputStream;
import java.io.OutputStream;
import java.net.Socket;
import java.net.UnknownHostException;
import java.util.Scanner;
/**
* Client program common to all the clients.
*
* @author Shweta Yakkali
* @author Aishwarya Desai
*/
public class Client4 {
/**
* The main() method contains the logic where the client reads the messages
* from the server.
*
* @exception EOFException End Of File Exception
*/
public static void main(String[] args) throws UnknownHostException, IOException {
Socket socket = new Socket("localhost", 2511);
Scanner sc = new Scanner(System.in);
ServerThread4 st = new ServerThread4();
DataInputStream in = new DataInputStream(socket.getInputStream());
DataOutputStream out = new DataOutputStream(socket.getOutputStream());
//ObjectInputStream o = new ObjectInputStream(socket.getInputStream());
try {
while (!st.done) {
System.out.println(in.readUTF());
System.out.println(in.readUTF());
System.out.println(in.readUTF());
String guess = sc.next();
out.writeUTF(guess);
System.out.println(in.readUTF());
System.out.println(in.readUTF());
System.out.println(in.readUTF());
System.out.println(in.readUTF());
System.out.println(in.readUTF());
System.out.println(in.readUTF());
}
System.out.println(in.readUTF());
sc.close();
} catch (EOFException e) {
}
}
}