Thread: Best approach

  1. #1
    Registered User
    Join Date
    May 2006
    Posts
    30

    Best approach

    Hi,

    I'm creating a application witch is totally based on winsock. anyway, the thing is that he must have like 200 transactions with remote servers at the same time, you can compare it with a torrent downloader. there you also can have like 200 connections running synchronisly. I'm mostly using the UDP protocol with winsock 2. What would be a good approach to accomplish this, The only way i can think of right now is having 200+ threads running synchornisly next to each other each doing his own transactions. however, there must be a way better approach.

    I'm not a beginner in both programming or networking. Neither am i a expert, i just know some stuff, programming for a few years and i've got a few CCNA diploma's.

    Thanks already for your support,

    - Koen

  2. #2
    * Death to Visual Basic * Devil Panther's Avatar
    Join Date
    Aug 2001
    Posts
    768
    200 threads, hmm... NO. You will kill yourself.
    I would suggest select() + a few threads, but not 200.
    "I don't suffer from insanity but enjoy every minute of it" - Edgar Allen Poe

    http://www.Bloodware.net - Developing free software for the community.

  3. #3
    Registered User Tonto's Avatar
    Join Date
    Jun 2005
    Location
    New York
    Posts
    1,465
    Yeah you should really just be running a few threads and then queueing the ones that can't be served by those workers at that moment. It's just crazy to expect that all the clients will be served at once (think of a restaurant).

  4. #4
    Registered User
    Join Date
    May 2006
    Posts
    30
    probably i explained it wrong, the app aint a server. it is a serverscanner, what it does, it retrieves serverlists of many games and keeps scanning them as fast as possible.so how does the scanning work? well you send a query to a server, and you recieve a bunch of server information. this information is being processed in the application. the thing is that the app must run very fast because there might be something like a 100 000 gameservers wich all need to be scanned with the least time between them.

    The only thing is that my current design pattern sucks ( i know ), it just creates a bunch of threads witch all gets a server and port and game from the controller class. then they scan the gameserver retrieves the information, uses the information and requests a new ip, port and game from the controller to start the whole process over again.

    The thing is that every thread have to wait for recv to finish, aka: most of the time, the threads are just in blocking mode or sleeping.

    So i need to know if there's a better approach (actually, i know there is i just need to know how it works. not the technical aspects, i can figure them out. just need a kick in the right direction )

  5. #5
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    You can make one thread that sends and receives requests and puts dta into queue for processing
    and several threads processing items from the queue
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

  6. #6
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    IO completion ports are an option.

  7. #7
    Registered User
    Join Date
    May 2006
    Posts
    30
    Quote Originally Posted by anonytmouse
    IO completion ports are an option.
    Thanks, that was exactly the answer that i needed.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Unsure on how to approach this concurrency problem
    By osiris^ in forum C# Programming
    Replies: 3
    Last Post: 04-29-2008, 11:47 PM
  2. How to approach this ...
    By Lord CyKill in forum C++ Programming
    Replies: 3
    Last Post: 02-14-2005, 04:52 PM
  3. Angle of approach for C++
    By mepaco in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 12-13-2002, 07:08 PM
  4. right approach!
    By tarun in forum C Programming
    Replies: 14
    Last Post: 08-19-2002, 08:00 PM
  5. software development approach...
    By dkt in forum A Brief History of Cprogramming.com
    Replies: 6
    Last Post: 10-16-2001, 09:15 PM