Skip to content

Instantly share code, notes, and snippets.

@hamzamuric
Created December 7, 2022 23:00
Show Gist options
  • Save hamzamuric/66d33ef1d807889b4152402aad66a674 to your computer and use it in GitHub Desktop.
Save hamzamuric/66d33ef1d807889b4152402aad66a674 to your computer and use it in GitHub Desktop.
import java.net.ServerSocket;
import java.net.Socket;
import java.util.Scanner;
import java.io.PrintWriter;
import java.io.IOException;
class Client {
public static void main(String[] args) throws IOException {
int host = 3000;
Socket socket = new Socket("localhost", 3000);
Scanner in = new Scanner(socket.getInputStream());
PrintWriter out = new PrintWriter(socket.getOutputStream(), true);
Scanner console = new Scanner(System.in);
while (true) {
String odgovori = console.nextLine();
out.println(odgovori);
String licnost = in.nextLine();
System.out.println(licnost);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment