Skip to content

Commit

Permalink
Update Client.java
Browse files Browse the repository at this point in the history
  • Loading branch information
Fedi6431 authored Jun 26, 2024
1 parent f5a6f5d commit d53f1be
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,13 @@ public class Client {
public Client(String address, int port) {
try {
// establish a connection with the server
System.out.println("Made by Fedi6431");
System.out.println("Client started");
System.out.println("\nClient started");
socket = new Socket(address, port);
System.out.println("Client connected");


// get input from the terminal
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

input = new DataInputStream(System.in);
// send output to the server socket
output = new DataOutputStream(socket.getOutputStream());

Expand Down Expand Up @@ -57,7 +55,7 @@ public Client(String address, int port) {
while (!line.equalsIgnoreCase("exit")) {
// get user input
System.out.print(clientIP + " to " + serverIP + "$-");
line = reader.readLine();
line = input.readLine();
// send the received input to the server
output.writeUTF(line);
}
Expand All @@ -78,6 +76,10 @@ public Client(String address, int port) {
}

public static void main(String args[]) {
Client client = new Client("127.0.0.1", 5000);
System.out.println("Made by Fedi6431");
System.out.println("Type server IPv4");
Scanner scanner = new Scanner(System.in);
String address = scanner.nextLine();
Client client = new Client(address, 5000);
}
}

0 comments on commit d53f1be

Please sign in to comment.