|
-
Mar 8th, 2010, 06:54 PM
#1
Thread Starter
New Member
fastest way to load multi sockets and threads?
I'm trying to figure out the best way to go about loading and using thousands of sockets at the same time.
Loading a new class for each instance would just destroy memory.
I'm assuming aysnc the sockets, my heads not straight at the moment.
plus it'd have to be on a seperate thread from freezing up the UI thread.
-
Mar 8th, 2010, 07:29 PM
#2
Re: fastest way to load multi sockets and threads?
 Originally Posted by mystical.net
I'm assuming aysnc the sockets, my heads not straight at the moment.
plus it'd have to be on a seperate thread from freezing up the UI thread.
That's exactly what "async" means. You create as many objects as your app requires. You call the appropriate asynchronous method of your Socket or whatever and then you get notified when data is received. It uses the TcpClient class rather than the Socket class but you might like to follow the CodeBank link in my signature and check out my Asynchronous thread. It should give you some ideas.
Any app that needs to open thousands of sockets is going to be resource intensive whether you like it or not. I hope you don't plan on running much else on the system at the same time.
-
Mar 8th, 2010, 07:55 PM
#3
Re: fastest way to load multi sockets and threads?
You're going to destroy more than memory, but memory is cheap, so don't worry about that aspect. I would be much more concerned about dealing with thousands of sockets. Do they HAVE to be opened at the same time? If you get reads on all of them at the same time, performance will be approaching zero. You may, effectively, DOS yourself. How about having a pool of active sockets with a maximum size, and only open more as active sockets close.
My usual boring signature: Nothing
 
-
Mar 8th, 2010, 11:03 PM
#4
Thread Starter
New Member
Re: fastest way to load multi sockets and threads?
Yeah, I'm not quite sure how i want to go about it, I'll give the general concept key word of it'd be doing which would be "Scanning", Last night i tried using a small class for each "Scan socket" worked out well, except loading a new instance of a class was just huge memory fail + slow loading of each class @ 2000 sockets, which is what i have the programmed set for max. as for when they started to scan they scanned real fast and well, about 700 address per second.
I use a track bar to determine how many you'd want loaded from 1-2000.
Now if i want to load as a socket array, that takes no more then 1 second to load 2000, but if they are all on the UI thread freezing may occur or they'll slowly go in order 1 by 1 to connect. Best i can assume is they almost all need there own thread to start connecting right away.
The sources in the code bank that I've looked at can't quite handle this case.
If it was a few sockets like 20, I'd have no problems, I'd prefer not to use TCPClient if i don't have to.
-
Mar 8th, 2010, 11:13 PM
#5
Re: fastest way to load multi sockets and threads?
The description of your app is still a bit vague but it might be that your best bet is to use the ThreadPool directly. Just queue up all your operations and let the system optimise it.
-
Mar 9th, 2010, 01:18 AM
#6
Thread Starter
New Member
Re: fastest way to load multi sockets and threads?
okay actual definition would be proxy scanner
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
|