0% found this document useful (0 votes)
3 views2 pages

Chatting Application Using Java Socket Programming

The document contains Java code for a simple chatting application using socket programming. It includes two classes, MyServer and MyClient, which handle server and client functionalities respectively, allowing for message exchange until the user types 'end'. The server listens on port 5555 and the client connects to it using a specified IP address.

Uploaded by

ramkeltesfa246
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views2 pages

Chatting Application Using Java Socket Programming

The document contains Java code for a simple chatting application using socket programming. It includes two classes, MyServer and MyClient, which handle server and client functionalities respectively, allowing for message exchange until the user types 'end'. The server listens on port 5555 and the client connects to it using a specified IP address.

Uploaded by

ramkeltesfa246
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Chatting Application using Java Socket Programming

//[Link]

package myserver;
import [Link].*;
import [Link].*;
public class MyServer {
public static void main(String[] args){
try{
ServerSocket ss=new ServerSocket(5555); //creating the server
Socket s=[Link]();//establishes connection
DataInputStream din=new DataInputStream([Link]());
DataOutputStream dout=new DataOutputStream([Link]());
BufferedReader br=new BufferedReader(new InputStreamReader([Link]));
String msgin="",msgout="";
while(![Link]("end")){
msgin=[Link]();
[Link](msgin);
msgout=[Link]();
[Link]("server: " +msgout);
[Link]();
}
[Link]();
}catch(Exception e){
[Link](e);
} } }
///[Link]

import [Link].*;
import [Link].*;
public class MyClient {
public static void main(String[] args) {
try{ Socket s=new Socket("[Link]",5555);
DataInputStream din=new DataInputStream([Link]());
DataOutputStream dout=new DataOutputStream([Link]());
BufferedReader br=new BufferedReader(new InputStreamReader([Link]));
String msgin="",msgout="";
while(![Link]("end")){
msgout=[Link]();
[Link]("Client: " +msgout);
msgin=[Link]();
[Link](msgin);
}
}
catch(Exception e){
[Link](e);
} }
}

You might also like