import java.net.*; import java.io.*; public class ServerSide { public static void main(String args[]) { try { ServerSocket ss = new ServerSocket(8888); System.out.println("Waiting..."); Socket server=ss.accept(); PrintStream ps= new PrintStream(server.getOutputStream()); ps.print("Hello..."); ps.flush(); System.out.println("Data Sent..."); } catch(Exception e) { System.out.println("Error : " + e.toString()); } } }
import java.net.*; import java.io.*; public class ClientSide { public static void main(String args[]) { try { String str= new String(); Socket client=new Socket(InetAddress.getLocalHost(),8888); BufferedReader br = new BufferedReader(new InputStreamReader(client.getInputStream())); if(br.ready()) { str=br.readLine(); System.out.println(str); } else { System.out.println("Data not ready to read from Stream"); } } catch(Exception e) { System.out.println("Error : " + e.toString()); } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)