Results 1 to 8 of 8

Thread: Multithreaded proxy checker

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2011
    Posts
    10

    Multithreaded proxy checker

    So I started writing proxy checker, I figured out responses from proxyjudge etc. but next step makes my head hurts...
    Multithreading based on 20 connections at time with replacing finished with new one...
    So basically Im trying to create 20 threads that will work on connect function.

    I already tried 2 function with threading like this(pseudocode) ->
    Code:
    Thread[] ts=new Thread[20]
    for(i=0;i<20;i++)
    ts[i]=new Thread(connect)
    ts[i].start()
    But in that method I couldn`t figure out how to make them work on next proxies with return stuff, so I tried to make "connect" to return the class(structure) with results, 2 fails in this method -> couldn`t get like i said to go with next 20 proxies, could get results in proper way

    2nd function ->
    I used threadpool but I could make it asynchronous to make thread wait for return from httpwebrequest...

    If anyone have idea how to deal with that please post it
    ps. I want to make something similar to "Charon" -> project2025 site

  2. #2
    Lively Member
    Join Date
    Apr 2010
    Posts
    121

    Re: Multithreaded proxy checker

    I'm not quite sure what you are asking?

    For managing threads, I would probably use 21 threads, one thread as the parent that manages the other 20.

    For example (this won't compile, I'm just giving you ideas):

    Code:
    Thread[] ts = new Thread[20]
    for(i=0;i<20;i++)
    {
        ts[i]=new Thread(new ThreadStart(connect))
        ts[i].start()
    }
    
    while(true)
    {
    foreach(Thread thrd in ts)
    {
         if(!thrd.IsAlive)
         {
               thrd.Abort();
               thrd = new Thread(new ThreadStart(connect));
         }
    }
    }
    I will get back to you with a more appropriate implementation once I get home, but I would love some more information on what you want, exactly.

    -jD

  3. #3

    Thread Starter
    New Member
    Join Date
    Sep 2011
    Posts
    10

    Re: Multithreaded proxy checker

    Thanks for replying... in short I will explain

    20x threads working on 1 proxy each...

    I made other class for checking proxies... so I need a method to return status of proxy from thread,,, I tried to make something like this :

    Code:
    public Result(class with results below) connect()
    {
    //checking
    }
    
    public Result()
    {
     public string result{get;set;}
    public int counter {get;set} /// counter gives the 1 if proxy processed 0 if something was wrong, if 0 then proxy will be processed one more time
     }

  4. #4
    Lively Member
    Join Date
    Apr 2010
    Posts
    121

    Re: Multithreaded proxy checker

    EDIT: OMG IM SO STUPID! -.- Sorry, I have been writing VB all day!

    -jD
    Last edited by jduncanator; Jan 30th, 2012 at 01:53 AM.

  5. #5
    Lively Member
    Join Date
    Apr 2010
    Posts
    121

    Re: Multithreaded proxy checker

    vb Code:
    1. Thread[] ts = new Thread[20]
    2. for(i=0;i<20;i++)
    3. {
    4.     ts[i]=new Thread(new ThreadStart(connect))
    5.     ts[i].start()
    6. }
    7.  
    8. while(true)
    9. {
    10. foreach(Thread thrd in ts)
    11. {
    12.      if(!thrd.IsAlive)
    13.      {
    14.            thrd.Abort();
    15.            thrd = new Thread(delegate() { var someValue = connect(); });
    16.            MessageBox.Show((string)someValue);
    17.      }
    18. }
    19. }

    Try that... Just an Idea though :P

    -jD
    If I helped you, don't forget to Rate my Post

  6. #6

    Thread Starter
    New Member
    Join Date
    Sep 2011
    Posts
    10

    Re: Multithreaded proxy checker

    Okey I will test it today and reply

  7. #7

    Thread Starter
    New Member
    Join Date
    Sep 2011
    Posts
    10

    Re: Multithreaded proxy checker

    Quote Originally Posted by jduncanator View Post
    vb Code:
    1. Thread[] ts = new Thread[20]
    2. for(i=0;i<20;i++)
    3. {
    4.     ts[i]=new Thread(new ThreadStart(connect))
    5.     ts[i].start()
    6. }
    7.  
    8. while(true)
    9. {
    10. foreach(Thread thrd in ts)
    11. {
    12.      if(!thrd.IsAlive)
    13.      {
    14.            thrd.Abort();
    15.            thrd = new Thread(delegate() { var someValue = connect(); });
    16.            MessageBox.Show((string)someValue);
    17.      }
    18. }
    19. }

    Try that... Just an Idea though :P

    -jD
    Yours code won`t work because connect must return something and in first loop won`t start...

  8. #8
    Lively Member
    Join Date
    Apr 2010
    Posts
    121

    Re: Multithreaded proxy checker

    I know... i was giving ideas, not code

    -jD
    If I helped you, don't forget to Rate my Post

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width