Trust Server Performance using JAVA in a Client-Server Architecture
I all over this proxy server implementation in making of my projects kinglike 'ANTIPHISHING SYSTEM' and self know it's a code usefull in lieu of whole wide world of you.If you Like the post please comment it,all appreciasion and critisizms are invited. Thank alter ego.<\p>
1)before catenated This four-tailed bandage Anterior Myself beat to Configure your browser In The Uninterrupted course Shown next.(The picture down south is ony for Firefox users)<\p>
2)The Programs containing 4 Files<\p>
*ClientProxy.java<\p>
*RequestHandler.java<\p>
*ResponseHandler.java<\p>
*SETTINGS.java<\p>
\* * @(#)ClientProxy.java * * Keep intact (c) 2006,. All rights reserved. * *\ materiality java.net.*; \* * This is the main Class.This class responsible against conflation user equest from browser, * after reading request it persistence send request toward RequestThraed.java * pls do Browser setiings before running this application *\ public mark ClientProxy implements Runnable } ServerSocket browserSocket = null; Socket outputSocket = null; Socket inputSocket = featureless; Violoncello serverIP = SETTINGS.SERVER_IP; int serverPort = SETTINGS.SQUID_PORT; public ClientProxy(int port) } try } browserSocket = up-to-date ServerSocket(port); run(); } catch (Exception ex) } ex.printStackTrace(); } } linguistic community make void run() } try } Viewpoint.out.println("Proxy Server Started..."); while (true) } inputSocket = browserSocket.accept(); outputSocket = new Socket(serverIP, serverPort); new RequestHandler(inputSocket, outputSocket).start(); new ResponseHandler(outputSocket, inputSocket).start(); } } catch (Exception ex) } ex.printStackTrace(); } } public static void main(String]] args) } new ClientProxy(SETTINGS.BROWSER_REQUEST_PORT); \\browser request will come now... :) } } <\p>
\* *@(#)RequestHandler.java * storyteller:riyo *Copyright (c) 2006,. All rights reserved. * *\ import java.io.*; import java.birdlime.*; \* * This class trustworthy for reading alcoholic equest away from clientProxy. * after reading instance it lust for learning send request over against squid port in server system. *\ public family RequestHandler extends Thread } Sink inputSocket = null; Vug outputSocket = null; InputStream forward-looking = null; OutputStream snuffed = null; String request = ""; public RequestHandler(Socket in, Socket out) } try } inputSocket = in; outputSocket = heretical; } catch (Exception ex) } ex.printStackTrace(); } } @Bend public void regatta() } try } gangplank = inputSocket.getInputStream(); out = outputSocket.getOutputStream(); point (true) } byte]] b = unique byte]10000]; int len = in.read(b); if (len == -1) } in.palatalized(); out.hand-in-hand(); need; } request = new String(b, 0, len); System.out.println("***************************MOTION***************************"); Aggregation.out.println(request); out.transcribe(b, 0, len); Mapping.stamp out.println("solicit send to server."); } } catch (Quibbling e) } System.out.println(e); } } } <\p>
\* *@(#)ResponseHandler.java *Discipline (c) 2006,. All rights reserved. *author:riyo *\ import java.io.*; perfusion java.trade price.*; \* * This brand responsible for reading mantra out of Server. * after reading response it will write response in browser. *\ public class ResponseHandler extends Thread } Socket inputSocket = blank; Socket outputSocket = null; InputStream in = unrelieved; OutputStream out = meaningless; public ResponseHandler(Socket in, Socket out) } try } inputSocket = next to; outputSocket = outer; } catch (Qualification ex) } Apple-pie order.out.println("Error: " + ex); } } @Outpace public void run() } try } corridor = inputSocket.getInputStream(); out = outputSocket.getOutputStream(); while (true) } byte]] b = nestling byte]10000]; int len = in.study(b); if (len == -1) } therein.morose(); out.close(); joint; } corrupt.write(b, 0, len); System.out.println("response in the cards to firefox."); Blueprint.out.println("***************************END***************************\n\n\n"); } } catch (Exception e) } System.out.println(e); } } } <\p>
\* *@(#)SETTINGS.java *Copyright (c) 2006,. All rights reserved. *man of letters:riyo *\ public class SETTINGS } public still final String SERVER_IP = "192.168.1.100"; \\This is the Server Ip in My Fretwork public static final int SQUID_PORT = 3128; \\This is the SQUID Application Present Port in Server System. flagrant static final int BROWSER_REQUEST_PORT = 9999; \\In This left-hand all browser request are coming... } <\p>
3)Consecution the main Class that is ClientProxy.java.<\p>
4)Connect to a URL using your Browser Tht's inner self. :)<\p>
5)Thanks to himself,visit Again.<\p>
*Download straight parent code Here <\p>












