socket programming help


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: socket programming help

  1. #1
    Join Date
    Oct 2005
    Posts
    2

    socket programming help

    have a piece of code ,this code is working in a different program individually but it does not work in the proxy server. It extracts the response from the website and when i write it to a something like out.html it writes the whole page but it does not write back to the socket for the web browser.


    guys if any one of you has a idea why this happens ,please do reply.


    if(request.startsWith("CONNECT"))
    {
    url = request.substring(8,c-13);
    String raw_request=null;
    //raw_request = sslhandler(url);

    /******************* Creating and handling https requests ******************/
    // Socket socket = SSLSocketFactory.getDefault().createSocket(url, 443);
    SSLSocketFactory factory = (SSLSocketFactory)SSLSocketFactory.getDefault();
    SSLSocket sslsocket = (SSLSocket)factory.createSocket(url, 443);
    sslsocket.startHandshake();
    //try
    // {
    //Writer sout = new OutputStreamWriter(socket.getOutputStream());
    PrintWriter sout = new PrintWriter(new BufferedWriter(new OutputStreamWriter(sslsocket.getOutputStream())));
    sout.println("GET / HTTP/1.0");
    //sout.
    sout.println();
    sout.flush();
    if (sout.checkError())
    System.out.println("SSLSocketClient: java.io.PrintWriter error");

    //OutputStream socket_out = socket.getOutputStream();
    //request = request + "\r\n";
    //socket_out.write(request.getBytes());*/
    InputStream sin = sslsocket.getInputStream();
    BufferedReader in1 = new BufferedReader(new InputStreamReader(sin));
    raw_request = getRawRequest1(sin);
    System.out.println(raw_request+"\r\n");

    /*************Transferring requested Web Page to Web Browser************/
    //out.write(raw_request.getBytes());
    String inputLine;
    PrintWriter out1 = new PrintWriter(new BufferedWriter(new OutputStreamWriter(out)));
    while ((inputLine = in1.readLine()) != null)
    out1.println(inputLine);
    //out.write(socket_in.read());
    Logobj.logEntry("Transferred "+raw_request.length()+" bytes of data to browser of "+socket.getInetAddress() + ":" +socket.getPort());
    ppt.doit("Transferred "+raw_request.length()+" bytes of data to browser of "+socket.getInetAddress() +":"+socket.getPort(),jta);
    out1.flush();
    sout.close();
    sin.close();

  2. #2
    Join Date
    Jul 2005
    Location
    SW MO, USA
    Posts
    299
    Are you able to get the SSL on port 443 to work? I was never able to get it to work on my proxy server.

  3. #3
    Join Date
    Oct 2005
    Posts
    2

    i use JSEE

    I can get the SSL on port 443 to work because I used JAVA secure sockets extension (JSSE version 1.5) and have a socket for the web-browser but that socket is not letting me write the output/resulting data of Port 443 onto the web browser. If writing to IE, it says "unknown ______" some sorta error and IE terminates. Tried it in firefox too, firefox says page not available.


    any idea why this happens norm , any suggestions would be appreciated.

Similar Threads

  1. Socket programming
    By eagle in forum Mobile
    Replies: 12
    Last Post: 09-22-2007, 08:51 AM
  2. socket programming
    By vinodkalpaka in forum Java
    Replies: 4
    Last Post: 06-29-2005, 12:47 AM
  3. Socket programming
    By eagle in forum .NET
    Replies: 0
    Last Post: 04-12-2005, 11:19 AM
  4. Books on socket programming?
    By Lim Wing Hoe in forum Java
    Replies: 0
    Last Post: 07-01-2000, 02:07 PM
  5. socket programming
    By Rajesh in forum Java
    Replies: 1
    Last Post: 04-25-2000, 08:27 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center