Client side

A Java program for Two-way Socket Programming ( Client side)
 avatar
user_9332925630
java
2 years ago
976 B
2
Indexable
Never
//A Java program for Two-way Socket Programming ( Client side)
package cnlabreport3;
import java.net.*;
import java.io.*;

public class Client {
 public static void main(String args[])throws IOException{
        Socket s = new Socket("aman",5000);
        
        System.out.println("Client connected!!!");
        DataOutputStream output = new DataOutputStream(s.getOutputStream());    
        BufferedReader read = new BufferedReader(new InputStreamReader(System.in));
        
        DataInputStream input = new DataInputStream(s.getInputStream());
        String str2 = "";
        
        String str ="";
        while(!str.equals("bye") && !str2.equals("bye")){
            str = read.readLine();
            output.writeUTF(str);
            
            str2=input.readUTF();
            System.out.println("Server says: "+str2);
        }
        input.close();
        output.close();
        read.close();
        s.close();
  }
}