Created
June 29, 2017 06:42
-
-
Save vnkdj5/5ec9a736efcca9fc01897a12688b95c2 to your computer and use it in GitHub Desktop.
Client Application for Echo (Chat) Server
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.net.*; | |
import java.io.*; | |
public class Client { | |
public static void main(String[] args) throws Exception { | |
Socket s=new Socket("localhost",8088); | |
DataInputStream din=new DataInputStream(s.getInputStream()); | |
DataOutputStream dout=new DataOutputStream(s.getOutputStream()); | |
BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); | |
String str="",str2=""; | |
while(!str.equals("stop")){ | |
System.out.println("\nEnter Response: "); | |
str=br.readLine(); | |
dout.writeUTF(str); | |
dout.flush(); | |
System.out.println("Waiting for Server's Reply..."); | |
str2=din.readUTF(); | |
System.out.println("Server says: "+str2); | |
} | |
dout.close(); | |
s.close(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment