Add to Favorites    Make Home Page 1396 Online  
 Language Categories  
 Our Services  

Home » Java Home » GUI Home » Server Client project to get PC health of remote sever (Mini Project)

A D V E R T I S E M E N T

Search Projects & Source Codes:

Title Server Client project to get PC health of remote sever (Mini Project)
Author kavita
Author Email kavita_bhndave [at] yhoo.co.in
Description Server Client project to get PC health of remote sever
Category Java » GUI
Hits 397696
Code Select and Copy the Code
Code : // To be run at server side and will act as a server // MainServer.java import java.net.*; import java.io.*; public class MainServer { public static void main(String[] args) throws IOException { ServerSocket serverSocket = null; try { serverSocket = new ServerSocket(4445); } catch (IOException e) { System.err.println("Could not listen on port: 4445."); System.exit(1); } Socket clientSocket = null; try { clientSocket = serverSocket.accept(); } catch (IOException e) { System.err.println("Accept failed."); System.exit(1); } PrintWriter out = new PrintWriter(clientSocket.getOutputStream(),true); BufferedReader in = new BufferedReader( new InputStreamReader( clientSocket.getInputStream())); String inputLine, outputLine; MainProtocol kkp = new MainProtocol(); // outputLine = kkp.processInput(null); // out.println(outputLine); while ((inputLine = in.readLine()) != null) { if (inputLine.equals("bye")) break; outputLine = kkp.processInput(inputLine); out.println(outputLine); outputLine = null; } out.close(); in.close(); clientSocket.close(); serverSocket.close(); } } // Server side component used to execute commands and returning result // MainProtocol.java import java.lang.*; import java.io.*; public class MainProtocol { String sa,sb; // String sb,sa; public String processInput(String args) { try { sb = new String(); sa = new String(); Runtime rt=Runtime.getRuntime(); Process p=rt.exec("cmd /c "+ args); InputStream is = p.getInputStream(); BufferedReader br = new BufferedReader(new InputStreamReader(is)); while ((sb = br.readLine()) != null) { sa += sb ; // sa +=" "; } p.waitFor(); System.out.println("process "+p.exitValue()); } catch(Exception e) { System.out.println(e.getMessage()+ "sumit"); } return sa ; } } // Client side component. Commands are to fired from here only // MainClient.java import java.io.*; import java.net.*; public class MainClient { public static void main(String[] args) throws IOException { Socket kkSocket = null; PrintWriter out = null; BufferedReader in = null; try { kkSocket = new Socket("10.37.32.74", 4445); out = new PrintWriter(kkSocket.getOutputStream(), true); in = new BufferedReader(new InputStreamReader(kkSocket.getInputStream())); } catch (UnknownHostException e) { System.err.println("Exception " + e); System.exit(1); } catch (IOException e) { System.err.println("Couldn't get I/O for the connection."); System.exit(1); } BufferedReader stdIn = new BufferedReader(new InputStreamReader(System.in)); String fromServer; String fromUser; while ((fromUser = stdIn.readLine()) != "hi") { // System.out.println("Server: " + fromServer); // if (fromServer.equals("Bye.")) // break; // fromUser = stdIn.readLine(); if (fromUser != null) { // System.out.println("Client: " + fromUser); out.println(fromUser); fromServer = in.readLine(); System.out.println("Server Response: "+ fromServer); fromServer = null; if (fromUser.equals("bye")) break; } } out.close(); in.close(); stdIn.close(); kkSocket.close(); } }

Related Source Codes

Script Name Author
Sending mail Using JavaMail to Yahoo and Gmail accounts sai prasad
Simple Program in Java to Implement Multithreading Satish.K
Simple Calculator in Java Using Remote Method Invocation Satish.K
Guest Book Application Using Servlets Satish.K
String Manipulation Using Stringification Satish.K
String Manipulation Using Stringification Satish.K
Moving Ball Application Using Java Beans Satish.K
Rapid Roll game subrahmanyeswararao
student mgm arpan
Sourav Datta
Download Manager Sagar
Address Book in Java Rahul Chouhan
address book using java database connectivity(jdbc-msaccess) shekhar bansal
sun Steganography B.Rajavel
Connecting Java with MS-Access - Inserting data in Aseem

A D V E R T I S E M E N T




Google Groups Subscribe to SourceCodesWorld - Techies Talk
Email:

Free eBook - Interview Questions: Get over 1,000 Interview Questions in an eBook for free when you join JobsAssist. Just click on the button below to join JobsAssist and you will immediately receive the Free eBook with thousands of Interview Questions in an ebook when you join.

New! Click here to Add your Code!


ASP Home | C Home | C++ Home | COBOL Home | Java Home | Pascal Home
Source Codes Home Page

 Advertisements  

Google Search

Google

Source Codes World.com is a part of Vyom Network.

Vyom Network : Web Hosting | Dedicated Server | Free SMS, GRE, GMAT, MBA | Online Exams | Freshers Jobs | Software Downloads | Interview Questions | Jobs, Discussions | Placement Papers | Free eBooks | Free eBooks | Free Business Info | Interview Questions | Free Tutorials | Arabic, French, German | IAS Preparation | Jokes, Songs, Fun | Free Classifieds | Free Recipes | Free Downloads | Bangalore Info | Tech Solutions | Project Outsourcing, Web Hosting | GATE Preparation | MBA Preparation | SAP Info | Software Testing | Google Logo Maker | Freshers Jobs

Sitemap | Privacy Policy | Terms and Conditions | Important Websites
Copyright ©2003-2024 SourceCodesWorld.com, All Rights Reserved.
Page URL: http://www.sourcecodesworld.com/source/show.asp?ScriptID=979


Download Yahoo Messenger | Placement Papers | Free SMS | C Interview Questions | C++ Interview Questions | Quick2Host Review