Tuesday, 9 June 2015

Corba program of UDP client server application which sends the news to the client. Server takes the news from the NewsDataFile located at the server


Code for Corba program of UDP client server application which sends the news to the client. Server takes the news from the NewsDataFile located at the server in Java



 



 



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

publicclass news_server
{
 publicstaticvoid main(String[] args) throws IOException 
 {
  int ch1;
  String str;
    FileReader fr = new FileReader("news.txt");
    BufferedReader br = new BufferedReader(fr);
 

  Socket C = new Socket("localhost",4000);
  OutputStream out = C.getOutputStream();

  DataOutputStream Dos = new DataOutputStream(out);

  
  while( (str = br.readLine()) != null)
  {
         Dos.writeUTF("Latest News (From Server ) :: " + str);
  }
  Dos.flush();
  fr.close();
 }
}


// Client//                               Client //               =====    


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

publicclass news_client
{
 publicstaticvoid main(String[] args) throws IOException 
 {
  ServerSocket S = new ServerSocket(4000);
  Socket Client = S.accept();
  InputStream in = Client.getInputStream();
  DataInputStream Dis = new DataInputStream(in);
  System.out.println(Dis.readUTF());
  Client.close();
 }
}


// OUTPUT
    
News.txt
=========================
India won the Worldcup by beating
Australia by 6 wkt.
===========================


//  Server
C:\jdk1.1.3\bin>javac news_server.java

C:\jdk1.1.3\bin>java news_server


//  Client
C:\jdk1.1.3\bin>java news_client
Latest News (From Server ) :: India won the Worldcup by beating
Australia by 6 wkt.

No comments:

Post a Comment