//Server file
import java.*;
import java.io.*;
import java.net.*;
import java.util.*;

public class Myserver
{
 public static void main(String arg[])
 {
 try
 {
 ServerSocket ss = new ServerSocket(6666);
 Socket s = ss.accept();
 DataInputStream din = new DataInputStream(s.getInputStream());
 String str1 =(String)din.readUTF();
 System.out.print("Client Says : "+str1); 
 ss.close();
 }
 catch(Exception e)
 {} 
 }
 }
//Client file
import java.io.*;
import java.util.*;
import java.net.*;

public class Myclient
{
 public static void main(String arg[])
  {
    try
     {
	  Socket s = new Socket("Localhost",6666);	  
	  DataOutputStream dout = new       
 DataOutputStream(s.getOutputStream());	 
	  dout.writeUTF("Hello");
	  dout.flush();
	  dout.close();
	  s.close();
	  }	
	catch(Exception e)
     {	 
	  }	
	 
   }
 
 }
OUTPUT
Click on Image to open 
Server File Execution :

sever

Client File Execution :

client

Leave a Reply

Subscribe to Posts | Subscribe to Comments

All Notes on BCA

All Notes  on BCA
BCA all subjects notes

Total Pageviews

Translate

Powered by Blogger.

Copyright © All Notes on BCA