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

  • SEARCH
  • Home
  • 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 6061699
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T08:58:00+00:00 2026-05-23T08:58:00+00:00

I’m trying to test a SOCKS proxy that’s under load from multiple machines. The

  • 0

I’m trying to test a SOCKS proxy that’s under load from multiple machines. The outline of my code is something along the lines of

  1. Connect directly to the server with one client, download the test file, and record the time it took.
  2. Connect through the proxy with one client, download the test file, and record the time it took.
  3. Connect through the proxy with multiple clients, download the test file, record the time.

1 and 2 are performed in the same function.

private static void baseline() {
    Download withProxy = new Download(socksPort, targetFile);
    Download withoutProxy = new Download(true, socksPort, targetFile); //The true argument just indicates not to use the proxy.


    try { //Come to think of it, I could just call run() directly here since this part is meant to be done serially.
        withProxy.start();
        withProxy.join();
        withoutProxy.start();
        withoutProxy.join();
                    //Some code for getting the times goes here.
    } catch (Exception e) {
        System.out.println("Couldn't get baseline.");
        e.printStackTrace();
    }
}

The download object inherits from Thread. Most of the work is done in the run() method, which looks like this:

public void run() {
    try {
        URL url = new URL("http://" + targetFile); 
        URLConnection urconn = null;
        if (baseline) {
            urconn = url.openConnection(Proxy.NO_PROXY); 
        } else {
            Proxy proxy = new Proxy(Proxy.Type.SOCKS, proxyAddr);
            urconn = url.openConnection(proxy); 
        }
        InputStreamReader isr = new InputStreamReader(urconn.getInputStream());
        System.out.println("Thread " + id + " is downloading.");
        long startTime = System.currentTimeMillis();
        char[] buf = new char[64];
        while (isr.read(buf) != -1) {
            ;
        }   
        long endTime = System.currentTimeMillis();
        isr.close();
        System.out.println("Thread " + id + " has completed.");
        delta = (endTime - startTime);

    } catch (Exception e) {
        e.printStackTrace();
        System.exit(1);
    }
}

The problem is that when I call the baseline function, it always uses the first choice of proxy – if I run the withproxy thread first, the withoutproxy thread will use the proxy. If I run withoutproxy first, withproxy ignores the proxy. The really odd thing is that later on when I try to connect through the proxy with multiple clients, it doesn’t matter how the baseline connections worked – if the baseline connection didn’t use a proxy, the multiple client connections still do.

What am I missing here?

Thanks

  • 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. Editorial Team
    Editorial Team
    2026-05-23T08:58:01+00:00Added an answer on May 23, 2026 at 8:58 am

    I managed to fix it – For whatever reason, the time between subsequent calls to url.openconnection() makes a difference. Calling Thread.sleep(10000) between each start() works.

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm trying to create an if statement in PHP that prevents a single post
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into

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.