Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 123651
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T04:19:13+00:00 2026-05-11T04:19:13+00:00

I am writing somewhat of a proxy program in Java. Here’s how it works:

  • 0

I am writing somewhat of a proxy program in Java. Here’s how it works:

  1. The browser will be connected to the program.
  2. Any requests by the browser will be first be printed out to standard out, then forwarded to the server.
  3. The server then returns a response, which is also printed to standard out, then forwarded back to the browser.

My problem is, step 1 works, step two works, but step 3 fails. The program can get a response, and its printed off to standard out properly, but the browser can’t seem to get it. I’ve modified the program to isolate the problem.

All its doing here, is printing the response directly to the browser:

 ServerSocket client = null;  try {       client = new ServerSocket(snoopPort);  } catch (IOException e) {       System.out.println('ERROR: Could not listen on port: ' + snoopPort);       System.exit(-1);  }   Socket clientSocket = null;  try {       clientSocket = client.accept();  } catch (IOException e) {       System.out.println('ERROR: Accept failed on port: ' + snoopPort);       System.exit(-1);  }   PrintWriter snoopOut = new PrintWriter(clientSocket.getOutputStream(), true);   snoopOut.print('HTTP/1.1 200 OK\r\n');  snoopOut.print('Date: Thu, 05 Feb 2009 06:37:28 GMT\r\n');  snoopOut.print('Server: Apache\r\n');  snoopOut.print('Set-Cookie: Apache=99.245.58.244.1233815848703045; path=/\r\n');  snoopOut.print('Accept-Ranges: bytes\r\n');  snoopOut.print('Transfer-Encoding: chunked\r\n');  snoopOut.print('Content-Type: text/html\r\n');  snoopOut.print('\r\n');  snoopOut.print('<html><head><title>test</head><body>hello world!</body></html>\r\n');   snoopOut.close();   clientSocket.close();  client.close(); 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T04:19:13+00:00Added an answer on May 11, 2026 at 4:19 am

    Okay. I’ve semi-figured out the problem. The code? its perfect. Everything works. It was the environment I was running under.

    I was testing it on a vista machine, and despite disabling all anti-virus and firewalls, it wouldn’t let me connect to the port. When I took it back to work, it was flawless. Why? I still have to figure it out. But thanks for the help everyone!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 70k
  • Answers 70k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer Make the constructors in Player have package access only. Then… May 11, 2026 at 12:55 pm
  • added an answer It is looking at the project description on the server;… May 11, 2026 at 12:55 pm
  • added an answer Following the comments... The reason nobody has probably ever done… May 11, 2026 at 12:55 pm

Related Questions

I am writing somewhat of a proxy program in Java. Here's how it works:
I am writing an application that downloads large files in the background. All clients
I am writing a query in which I have to get the data for
I am writing a few extensions to mimic the map and reduce functions in
I am writing a client-side Swing application (graphical font designer) on Java 5 .
I've got a somewhat dated Java EE application running on Sun Application Server 8.1
I have a friend who is finishing up his masters degree in aerospace engineering.
I am writing a simple Python web application that consists of several pages of
I am writing a little application to download files over http (as, for example,

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.