Write the program Server And Client between Connection and get the Message In java - LearnHowToCode SarkariResult.com Interview Questions and Answers LearnHowToCodeOnline
Write the program Server And Client between Connection and get the Message In java

Write the program Server And Client between Connection and get the Message In java

 Server  And Client  between Connection

Server :


import java.io.*;
import java.net.*;

class Server
{
 public static void main(String[]args)
 {
   try
   {
     ServerSocket ss=new ServerSocket(6666);
Socket s=ss.accept();
System.out.println("socket connection etablished");
DataInputStream dis=new DataInputStream(s.getInputStream());
String str =(String)dis.readUTF();
System.out.println("message="+str);
}
catch(Exception e)
{

System.out.println(e);
}
 }
}

Client:

import java.io.*;
import java.net.*;

class Client
{
 public static void main(String[]args)
 {
   try
   {
   
Socket s=new Socket("localhost",6666);
DataOutputStream dis=new DataOutputStream(s.getOutputStream());
   dis.writeUTF("hello server");
   dis.flush();
   dis.close();
 

}
catch(Exception e)
{

System.out.println(e);
}
 }
}



About EasyToCode

I'm Ethan Mariano a software engineer by profession and reader/writter by passion.I have good understanding and knowledge of AngularJS, Database, javascript, web development, digital marketing and exploring other technologies related to Software development.

0 comments:

Featured post

Political Full Forms List

Acronym Full Form MLA Member of Legislative Assembly RSS Really Simple Syndication, Rashtriya Swayamsevak Sangh UNESCO United Nations E...

Powered by Blogger.