-
Notifications
You must be signed in to change notification settings - Fork 38
Expand file tree
/
Copy pathClient.java
More file actions
35 lines (31 loc) · 1.24 KB
/
Client.java
File metadata and controls
35 lines (31 loc) · 1.24 KB
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
package sbu.cs.Client;
import java.io.*;
import java.net.Socket;
import java.util.Scanner;
// Client Class
public class Client {
// TODO: Implement the client-side operations
// TODO: Add constructor and necessary methods
private static final String SERVER_IP = "127.0.0.1";
private static final int SERVER_PORT = 3000;
public static void main(String[] args) throws IOException {
// TODO: Implement the main method to start the client
Socket client = new Socket(SERVER_IP, SERVER_PORT);
Boolean IsInChat = false;
DataOutputStream out = new DataOutputStream(client.getOutputStream());
//DataInputStream in = new DataInputStream(.getInputStream());
System.out.println("Name:");
Scanner scanner = new Scanner(System.in);
String name = scanner.nextLine();
out.writeUTF(name);
HandleServerResponse Handle = new HandleServerResponse(client);
Thread Handlethread = new Thread(Handle);
Handlethread.start();
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String userInput;
while (true) {
userInput = reader.readLine();
out.writeUTF(userInput);
}
}
}