-
Jan 28th, 2012, 04:21 PM
#1
Thread Starter
New Member
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
-
Jan 28th, 2012, 06:27 PM
#2
Lively Member
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
-
Jan 29th, 2012, 02:27 AM
#3
Thread Starter
New Member
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
}
-
Jan 29th, 2012, 07:56 PM
#4
Lively Member
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.
-
Jan 30th, 2012, 08:40 PM
#5
Lively Member
Re: Multithreaded proxy checker
vb 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(delegate() { var someValue = connect(); }); MessageBox.Show((string)someValue); } } }
Try that... Just an Idea though :P
-jD
If I helped you, don't forget to Rate my Post
-
Jan 31st, 2012, 12:36 AM
#6
Thread Starter
New Member
Re: Multithreaded proxy checker
Okey I will test it today and reply
-
Feb 1st, 2012, 08:39 AM
#7
Thread Starter
New Member
Re: Multithreaded proxy checker
Originally Posted by jduncanator
vb 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(delegate() { var someValue = connect(); });
MessageBox.Show((string)someValue);
}
}
}
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...
-
Feb 2nd, 2012, 12:31 AM
#8
Lively Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|