-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathClient.java
56 lines (47 loc) · 1.52 KB
/
Client.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
package projectOS;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.net.Socket;
import java.net.UnknownHostException;
import java.util.Scanner;
public class Client
{
public static void main(String[] args) throws UnknownHostException, IOException
{
Scanner kb = new Scanner(System.in);
Socket s = new Socket("localhost",5002);
BufferedReader in = new BufferedReader(new InputStreamReader(s.getInputStream()));
PrintStream p = new PrintStream(s.getOutputStream());
System.out.println("Connected to "+s.getInetAddress()+":"+s.getPort());
System.out.println("Welcome to Parallel File Search Server Load Distributor!\r\n");
int userOption;
do {
System.out.println("Choose one of the following options:");
System.out.println("1. Equal Distribution");
System.out.println("2. Round Robin Distribution");
System.out.println("3. Quit");
userOption = kb.nextInt();
} while (userOption > 3 || userOption < 1);
System.out.println();
p.println(userOption);
if (userOption != 3) {
kb.nextLine();
System.out.print("Enter the path you'd like to search through: ");
String path = kb.nextLine();
System.out.print("Enter the word you'd like to search for: ");
String word = kb.nextLine();
p.println(path);
p.println(word);
System.out.println();
String output;
while ((output = in.readLine()) != null)
System.out.println(output);
}
in.close();
p.close();
kb.close();
s.close();
}
}