Last active
June 29, 2017 06:40
-
-
Save vnkdj5/df918a56260a29b169cc717e282e5d7f to your computer and use it in GitHub Desktop.
Echo Sever (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 Server { | |
public static void main(String args[]) throws Exception,UnknownHostException{ | |
ServerSocket ss=new ServerSocket(8088); | |
Socket s=ss.accept();; | |
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!="stop") | |
{ | |
System.out.println("Waiting for client's Reply..."); | |
str=din.readUTF(); | |
System.out.println("Client: "+str); | |
System.out.println("Enter Message:"); | |
str2=br.readLine(); | |
dout.writeUTF(str2); | |
dout.flush(); | |
} | |
din.close(); | |
s.close(); | |
ss.close(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment