Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C Windows programming udp , +
I have developed a single server multiple client udp application using multithreading. Now I want to implement the server using asynchronous sockets so that it may be able to handle multiple clients at a time. Will this approach work fine? Is it correct to use asynchronous socket if you want to handle multiple clients using one single server? Is using asynchronous socket a better approach than using threads for handling multiple clients?
Posted 19-Apr-13 1:45am
Comments
Matthew Faithfull at 19-Apr-13 6:48am
   
What advantage do you expect from async sockets if you're already using multithreading?
If your server has a thread per client you won't get any. If it is thread pooled you may get a big improvement.
If it is multithreaded and you can still only handle one client at a time you have bigger problems to deal with first.
ayesha hassan at 19-Apr-13 7:05am
   
If I have a single processor system and I can not implement multithreading, what am I supposed to do then in order to handle multiple clients in my server? :(
Matthew Faithfull at 19-Apr-13 9:10am
   
You can still implement multithreading on a single processor system and it can even have some advantages including actually simplifying the code in this kind of application.
There's no reason not to use async sockets it's just that if you have a working multithreaded system already then there's probably no need.
 
It is also possible to handle multiple clients very well in a single threaded system depending on the protocol in use and how asynchronous, intermitent and granular the overall system is.
It's not easy and some of the basic requirements are:
Each and every message must have a source identifier and message length, these should be at the head of the message.
Messages should be kept small, prefer many small messages over one large one.
Messages must of serialized before reaching your code, i.e. not interleaved with one another and each client must only send one message at a time.
I can't describe a full system for handling this here but it can be done with a lot of thought and a slightly unconventional queueing system. Be very sure this is the way you want to go before trying it.
ayesha hassan at 20-Apr-13 1:19am
   
I have always followed the concept that multithreading can only be implemented on multiple processors system where there are more than one processor to be assigned to each thread and each thread can be executed simultaneoulsy. There is no scheduling in this case as each of the thread has separate resources all dedicated to it.
what is the difference between single processor and multiple processor systems then? :(
I have posted another question here http://www.codeproject.com/Questions/580778/Canplusmultithreadingplusbeplusimplementedplusonpl

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 565
1 Maciej Los 319
2 Richard MacCutchan 220
3 BillWoodruff 164
4 Mathew Soji 160
0 OriginalGriff 8,654
1 Sergey Alexandrovich Kryukov 7,407
2 DamithSL 5,639
3 Maciej Los 5,229
4 Manas Bhardwaj 4,986


Advertise | Privacy | Mobile
Web03 | 2.8.1411023.1 | Last Updated 19 Apr 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100