Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.*;
- import java.net.*;
- public class MyClient{
- public static void main(String[] args) throws IOException{
- String hostname = "localhost";
- int port = Integer.parseInt(args[0]);
- while(true){
- try(Socket socket = new Socket(hostname ,port)){
- System.out.println("Connected!");
- InputStream input = socket.getInputStream();
- BufferedReader reader = new BufferedReader( new InputStreamReader(input));
- String data = reader.readLine();
- System.out.println(data);
- }
- catch(IOException e){
- System.out.println(e);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement